Description
Thanks for this Image uploader/resizer. I've been adapting it for another purpose (just the resizing part), and noticed a few things weren't working in my own testing. It looks like all are simple fixes, and just wanted to pass them along:
-
As far as I can tell, the client-side resizing does not come into play at all unless the
config.autoRotate
option istrue
. See this conditional. I basically just removed the autoRotate conditional and left everything within it, and it seems to work fine. -
The
config.maxSize
option doesn't appear to work as described in the README. It suggests that it is expecting a float like 1.7, but the actual code seems to be expecting something different. I was able to correct it by adjusting the maxSize part of thescaleImage
function to the following (though I'm guessing you know something better):
if(this.config.maxSize > 0 && (this.config.maxSize < (canvas.width * canvas.height) / 1000000)) {
var mSize = Math.floor(Math.sqrt(this.config.maxSize * ratio) * 1000);
mWidth = mWidth > 0 ? Math.min(mWidth, mSize) : mSize;
}
- As far as I can tell, your resizing code works equally well with png and gif files (?), once I replaced the static
image/jpeg
content-type from thecanvas.toDataURL()
call withthis.currentFile.type
at the bottom of thescaleImage
function. I changed it to this below, and it appears to be working, though I may be missing something.
var quality = this.currentFile.type == 'image/jpeg' ? this.config.quality : 1.0;
var imageData = canvas.toDataURL(this.currentFile.type, quality);