Image resize issue when actual image height/width is less then resize settings #108

anujkrathi opened this Issue Jul 3, 2013 · 3 comments


None yet

2 participants


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).
Works great.

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.

RubaXa commented Jul 3, 2013

You are absolutely right, I add checking.

RubaXa commented Jul 9, 2013

Try dev branch.

RubaXa commented Jul 15, 2013

Remember, the problem is fixed in dev branch.

@RubaXa RubaXa closed this Jul 15, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment