scottcheng / cropit

A "customizable crop and zoom" jQuery plugin.
http://scottcheng.github.io/cropit/
MIT License
874 stars 304 forks source link

Chrome generates blank base64 image (unless preresizedImage = this.image) #126

Closed narnigrin closed 8 years ago

narnigrin commented 8 years ago

Not exactly sure what happens here, but I've tested this on two separate machines and the same error appears.

When I use the plugin in Chrome 46.0.2490.80 on OSX, everything works fine until the point where I do a .cropit('export') to get the base64 for the cropped image. If I put that base64 string in an img src, the image comes up blank (I've tried copy+pasting it in another browser with the same result - the generated string really is just a blank image). If I try cropping the same original image file in Firefox, however, everything works.

I dug around a bit in cropit's code today and found that if I replace preresizedImage with this.image on line 674 of jquery.cropit.js (inside getCroppedImageData()), suddenly things seem to work in Chrome. (But obviously whatever preresizeImage() does, isn't applied ...)

Please let me know if you need any more info to understand and/or solve this issue.

scottcheng commented 8 years ago

I saw this issue first coming up on Safari, and have removed the use of presizeImage() to address that in 0.4.5. Are you using an older version of cropit?

narnigrin commented 8 years ago

Wow, yes, I downloaded version 0.4.4 in September and completely failed to notice the update. With 0.4.5 there's no problem. Thanks for the quick response - and apologies for taking up your time. Love the plugin. :-)

scottcheng commented 8 years ago

My pleasure :)