Open derwaldgeist opened 3 months ago
No issues with that here. I call loadImage with maxWidth=100 and maxHeight=100 and always get a thumbnail that's never larger than 100 pixels in any direction, and always proportioned in the same ratios of the original image.
Can you post your code?
Thanks for your response. I learned in the meantime that this only happens if you set cover
to true
. Yet I am still wondering why this flag overrides the maxWidth
/ maxHeight
settings?
Yes, your 3869x1024 resulting image is correct according to the code in:
https://github.com/blueimp/JavaScript-Load-Image/blob/master/js/load-image-scale.js
(search for cover
and follow the scaleUp
and scaledown
calcuations)
Not sure what the intention was by the author. As a workaround I'd probably just avoid the cover: true
parameter and let load-image return a ratio-correct image, and then stretch it in the displayed version.
Yes, that's what I am doing right now.
If I am calling loadImage with maxWidth = 1024, maxHeigth = 1024, I would expect that the neither the width nor the height exceed 1024. Instead, the library seems to set the shorter length to 1024, so the other can exceed its max value. Also, the library stretches the image even if it is smaller.
As an example, I have an input image that is 3560x942. The resulting image is 3869x1024, which is even bigger than the original, and the width is over 3x larger than the maxWidth.
This also happens if I set the maxHeight to 1024 only, i.e. without a maxWidth.
I would expect that maxWidth and maxHeight are maximum values, not minimum values?