Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Closed
jimlaren opened this issue Jan 10, 2012 · 8 comments
Closed

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

jimlaren opened this issue Jan 10, 2012 · 8 comments
Labels
Milestone

Comments

@jimlaren
Copy link

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.

@ghost
Copy link

ghost commented Jan 10, 2012

Jim,

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

@jimlaren
Copy link
Author

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)

@jimlaren
Copy link
Author

oh forget the parameter Scalr.Mode.FIT_EXACT

@ghost
Copy link

ghost commented Jan 10, 2012

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.

@ghost ghost closed this as completed Jan 10, 2012
@jimlaren
Copy link
Author

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.

@ghost ghost reopened this Jan 10, 2012
@ghost
Copy link

ghost commented Jan 10, 2012

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

Re-opening issue.

@ghost
Copy link

ghost commented Jan 11, 2012

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.

@ghost ghost closed this as completed Jan 11, 2012
ghost pushed a commit that referenced this issue Jan 11, 2012
added test-case to catch it in the future.

The stop-condition in incremental scaling (line 2266) was stopping too
early if either the width OR height didn't change between an incremental
scale.

Technically the incremental scaling shouldn't stop until BOTH dimensions
stop changing.

The fix was simple; change the check from || to &&.
@jimlaren
Copy link
Author

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

This issue was closed.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant