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

Closed
anujkrathi opened this Issue Jul 3, 2013 · 3 comments

Projects

None yet

2 participants

@anujkrathi

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;
}
else
{
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
Contributor
RubaXa commented Jul 3, 2013

You are absolutely right, I add checking.

@RubaXa
Contributor
RubaXa commented Jul 9, 2013

Try dev branch.

@RubaXa
Contributor
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