If I use FileAPI.Image().resize() with type "max", it works great & resize the image in aspect ratio & also according to the max side. (landscape or portrait).
But If actual image dimension is less the resize settings, output becomes wrong.
E.g: If I have defined resize settings as: resize(500, 500, 'max') & I try to resize an image ( actual image size is 293x466), then its dimension should be unchanged;
But FileAPI generating new image which dimension is 314x466. which is wrong & it also increases the size (in KB) of uploaded image. So, dimension calculation should be:
if(imageHight > imageWidth)
canvasHeight = ( imageHight > maxHeight ) ? maxHeight : imageHeight;
canvasWidth = (imageWidth / imageHeight) * canvasHeight;
canvasWidth = ( imageWidth > maxWidth ) ? maxWidth : imageWidth;
canvasHeight = (imageHeight / imageWidth) * canvasWidth;
in this way, If image dimension is less the resize settings, it will return the same dimension.
You are absolutely right, I add checking.
#108: Check width/height before resize by type(min/max)
Try dev branch.
Remember, the problem is fixed in dev branch.