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

[chore] Only call imaging.Resize when necessary, use even tinier blurhashes #3247

Merged
merged 3 commits into from
Aug 29, 2024

Conversation

tsmethurst
Copy link
Contributor

@tsmethurst tsmethurst commented Aug 29, 2024

Use imaging.Fit rather than imaging.Resize, as the former doesn't bother resizing the image if it's already inside the target dimensions, whereas the latter does, if I'm reading the code correctly.

EDIT: Actually I'm not quite right about that. Fit will leave the image alone if it's at or below the target dimensions. Resize will leave the image alone if it already equals the target dimensions, but scale it up or down if it's not. But in this case I don't think it makes a difference, because we calculate the thumb dimensions beforehand and pass it through to here, and if the image is already in-bounds of our thumbnail dimensions we just pass the original image dimensions. So no need for this change actually.

Only call imaging.Resize when necessary, to avoid unnecessary clone operation.

Also use an even tinier resize for blurhashes. Both of these changes just revert to behavior we had in 0.16.0 already, I think we just included these changes more or less by accident.

Draft because I need to update blurhashes in tests.

@tsmethurst tsmethurst changed the title [chore] Use imaging.Fit, use even tinier blurhashes [chore] Only call imaging.Resize when necessary, use even tinier blurhashes Aug 29, 2024
@tsmethurst tsmethurst marked this pull request as ready for review August 29, 2024 11:45
@tsmethurst tsmethurst merged commit e10aa76 into main Aug 29, 2024
3 checks passed
@tsmethurst tsmethurst deleted the imaging_tweaks branch August 29, 2024 15:43
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.

2 participants