Repository navigation
Keep at least one pixel when resizing by width or height - #334
Merged
freekmurze merged 1 commit intoOct 5, 2026
Merged
Conversation
width() and height() compute the other dimension with round(), which yields 0 for images with an extreme aspect ratio (e.g. a 588x1 divider resized to width 100). Size::resize() then divides by zero in aspectRatio(). Clamp to 1, as resizeWidth()/resizeHeight() already do.
freekmurze
approved these changes
Oct 5, 2026
freekmurze
left a comment
Member
There was a problem hiding this comment.
Looks good. The regression tests cover all three drivers, and CI is green.
Member
|
Thanks @patrickweh for the fix and regression tests! Merged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
width()andheight()compute the other dimension with(int) round(...). For images with an extreme aspect ratio that rounds to 0, for example a 588x1 divider line from an email signature resized withwidth(100).Size::resize()then turns the size into 0x0 and the nextaspectRatio()call throws:With Imagick the same input ends in a
ValueError. In laravel-medialibrary this fails the wholePerformConversionsJobas soon as such an image is attached.This clamps the computed dimension to at least 1 pixel in all three drivers, the same way
Size::resizeWidth()andSize::resizeHeight()already do. Tests cover a 588x1 image withwidth(100)and a 1x588 image withheight(100).