It is possible to enter an image through the click event

good morning,

they could help me since I’m doing a test to make a crop to the images with the “photo-up” package of meteor, and the package for the crop does it great but when doing cick in the crop it does not save the created image and by doing so through the Change event of the File button if you insert the image. but I want to save the image that is created when making the crop.

I share my crop code and I hope you can help me.

'click .crop': (e, tmpl) ->
    e.preventDefault()
    e.stopPropagation()

    if photoUpImage.get()? and PhotoUpCropCords.get()? # tmpl.cropCords?.get()?
      cropCords = PhotoUpCropCords.get() # tmpl.cropCords.get()
      #photo =  loadImage.scale photoUpImage.get()
      photo = photoUpImage.get()
      if photo.newImage
        console.log("save original") if DEBUG
        tmpl.originalPhoto.set(photo)

      console.log("Crop Image", cropCords, photoUpImage.get()) if DEBUG
      newImg = loadImage.scale photo.img,
        left: cropCords.x
        top: cropCords.y
        sourceWidth: cropCords.w
        sourceHeight: cropCords.h
        #minWidth: img.parent().width()
        canvas: true

      console.log("New Crop Image", newImg) if DEBUG
      newPhoto = _.extend {}, photo,
        img: newImg
        width: newImg.width
        height: newImg.height
        src: newImg.toDataURL()
        size: newImg.toDataURL().length
        newImage: false

      console.log("Remove Crop") if DEBUG
      removeJcrop(tmpl)
      tmpl.cropCords.set(null)
      PhotoUpCropCords.set(null)

      photoUpImage.set(newPhoto)

      imagenCrop = newPhoto.src
///////////// HERE IS WHERE I WANT TO SAVE THE IMAGE IN COLLECTION CREDENTIALS/////////////
      console.log(imagenCrop)
      FS.Utility.eachFile e, (imagenCrop) ->
      fileObj = new (FS.File)(imagenCrop)
       CropImagenCredencial.insert fileObj

      if imageIsValid()
        @callback?(null, newPhoto)

sorry i don’t have a direct answer, but have you looked at Cloudinary? they have a nice image api for doing things like this via query string params.

@danger190dr take a look on Meteor Files lib, it’s usage should be clear -

Do you get your file as base64 string or File object?

if friend you get a base64 chain when doing the crop!

:face_with_raised_eyebrow::thinking::point_right: Insert (Upload) · veliovgroup/Meteor-Files Wiki · GitHub