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)