Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix Image.Enlarge keep image size in boundaries #204

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jayme-github
Copy link
Contributor

Image.Enlarge does not always return an image that fits into the given
width and height boundaries.

To fix that, imageCalculations() now returns the maximum factor instead
if the minimum if no cropping is requested and the desired image is
bigger than the source.

Im not completely sure with this but I expected Image.Enlarge to always return images that don't exceed the width and height provided.

/cc @tback

Image.Enlarge does not always return an image that fits into the given
width and height boundaries.

To fix that, imageCalculations() now returns the maximum factor instead
if the minimum if no cropping is requested and the desired image is
bigger than the source.
@jayme-github
Copy link
Contributor Author

jayme-github commented Nov 2, 2017

Just discovered that this change does not fix all edge cases. Input of []int{412, 3460} still breaks the bounds:

image_test.go:150: Invalid image size: 421x316

factor = math.Min(xfactor, yfactor)
} else {
factor = math.Max(xfactor, yfactor)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi. this is a revert from #198 with an additional check. Might be better, indeed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the hint. Wat was the reason for removing the check in first place?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests were breaking.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, TestResizeVerticalImage fails with #198.
We see some shrinking issues introduced with #198, currently still under investigation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@greut please see #205

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants