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

Use percent orig width/height for down scaling #20

Merged
merged 1 commit into from
Sep 20, 2023

Conversation

benlubas
Copy link
Contributor

@benlubas benlubas commented Sep 20, 2023

This change better respects the users configured max width and height values when rendering an image. Addressing #19

higher level overview of how

When down-scaling images, we crush the image to the max height and width, and then attempt to restore the aspect ratio. When restoring the aspect ration, we now take the percentage of the original dimension (either width or height) that's smaller, keep that smaller value, and scale the other to match.

This should always be more accurate than what we were previously doing, which was just keeping the larger value and scaling the smaller value to match.

@3rd
Copy link
Owner

3rd commented Sep 20, 2023

This looks great, thank you!

Just noticed that the math.ceil there might make the images look worse than by using math.floor when setting max sizes.

Both will have an error margin, but floor seems closer to the original...
Think we should switch to floor?

original:
image

ceil + no max:
image

floor + no max:
image

ceil + max_width 5:
image

floor + max_width 5:
image

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

2 participants