rkalla / imgscalr

Simple Java image-scaling library implementing Chris Campbell's incremental scaling algorithm as well as Java2D's "best-practices" image-scaling techniques.

Home Page:http://www.thebuzzmedia.com/software/imgscalr-java-image-scaling-library/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

no resize when source image's width equals target image's width

jimlaren opened this issue · comments

no resize when source image's width equals target image's width.

the condition in the method scaleImageIncrementally

if (prevCurrentWidth == currentWidth
|| prevCurrentHeight == currentHeight)
break;

is true,so break out;

no resize when source image's height equals target image's height.

Jim,

This was done intentionally; can you describe your scenario and what the expected or preferred behavior would have been for you?

For example:source image:width=200 height=100,target image:width=200 height=50,the condition will be true,so there is no resize will happen.
(ps:forgive my poor english)

oh forget the parameter Scalr.Mode.FIT_EXACT

Jim, imgscalr is behaving as-designed, more information here: #63

As you found out, using the different Mode values can change the short-circuiting behavior.

I will close this issue for the same reason I closed Issue #64, but please let me know if you'd like to discuss this further or disagree with my reasoning and I will be happy to re-open it.

there is an introduction on the website
"The only way to force imgscalr to resize (stretching if necessary) an image into a target bounding box is to use Scalr.Mode.FIT_EXACT."
you have mentioned in the issue 63
"If you actually want to stretch the image to 200x80 (distortion and all) then use Mode.FIT_EXACT."

I always use the Mode.FIT_EXACT,but it doesn't work in the situation I mentioned above.I just comment the condition ant it works,but don't kown if there is any side effect.

Jim I will take a look and see if I have bug in there; thank you for clarifying.

Re-opening issue.

Jim,

Great catch; I did have a bug in there when FIT_EXACT is used, it should be an && condition and not a || condition on line 2267.

This will be fixed in the 4.2 release.

I should thank you,it's a great library.Thank you again.