Open mariopepe opened 2 years ago
I'm no expert with this package but I don't think this is possible with current code. This only scales up the image if its lesser than minHeight/minWidth but not scales down if passed image bytes are of higher resolution.
var scaleW = srcWidth / minWidth; var scaleH = srcHeight / minHeight; var scale = math.max(1.0, math.min(scaleW, scaleH));
math.max always returns 1 or >1, so scaling down is not available. May be, using math.min(1.0, math.min(scaleW, scaleH)) could help in our case.
The resize logic is extremely odd and confusing.
I've created a sheet that you can use to visualize what will happen with different parameters.
It can scale down, but has edge cases.
I would prefer to see a maxWidth
and maxHeight
and that it would keep it within those bounds but maintain the aspect ratio.
1) let's say I have an image 1000 x 1000, how can I BOTH compress the quality AND resize it to say 500 x 500 ?
2) I have seen in the docs srcWidth and srcHeight, what is this?
Thanks