[chore] Only call imaging.Resize when necessary
, use even tinier blurhashes
#3247
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.