User tests: Successful: Unsuccessful:
This issue was discovered in the Media Manager when the Create Thumbnails option is enabled in the Filesystem - Local plugin, and the folder contains an image with an extreme aspect ratio, e.g. 1000×2, 1920×4 or 2×1000.
LocalAdapter::createThumbnail() calls Image::createThumbnails() with SCALE_INSIDE, which goes through Image::resize() and Image::prepareDimensions().
When the shorter side is divided by the scale ratio in Image::prepareDimensions() and the result is below 0.5, it rounds to 0. That 0 is passed to imagecreatetruecolor(), which throws a ValueError and stops the Media Manager listing when thumbnails are enabled.
The same applies to any Image::resize() call using SCALE_INSIDE, SCALE_OUTSIDE or SCALE_FIT.
This change ensures that the width and height calculated by prepareDimensions() are at least 1px.
Enable Create Thumbnails in Filesystem - Local, upload a 1000×2 image (or 2×1000), and open that folder in the Media Manager.
The ValueError is thrown and the folder doesn't list, e.g.
imagecreatetruecolor(): Argument #2 ($height) must be greater than 0
The folder lists and a thumbnail of 200×1 is generated for the image.
Please select:
Documentation link for guide.joomla.org:
No documentation changes for guide.joomla.org needed
Pull Request link for manual.joomla.org:
No documentation changes for manual.joomla.org needed
| Status | New | ⇒ | Pending |
| Category | ⇒ | Libraries |
| Title |
|
||||||
| Labels |
Added:
PR-5.4-dev
|
||
I have tested this item ✅ successfully on 6c38d87
Hello @ryandemmer, thanks for this PR fix. I never had such an extreme image case but great find. In my case, I used an image of 2 x 3088 and initially without your fix I had the nice error :/ of:
imagecreatetruecolor(): Argument #1 ($width) must be greater than 0 and with your fix, the file gets correctly created to 1 x 200 in the /media/cache/thumbs folder 📻
| Title |
|
||||||
As 5.4 has reached end of bugfix support and is now in security only support mode, I've allowed myself to rebase this PR here to 6.2-dev, where bug fixes should be made now. This worked cleanly, so the previous human test is still valid.
| Labels |
Added:
bug
PR-6.2-dev
Removed: PR-5.4-dev |
||
I have tested this item ✅ successfully on 6c38d87
Hello @ryandemmer, thanks for this PR fix. I never had such an extreme image case but great find. In my case, I used an image of 2 x 3088 and initially without your fix I had the nice error :/ of:
imagecreatetruecolor(): Argument #1 ($width) must be greater than 0 and with your fix, the file gets correctly created to 1 x 200 in the /media/cache/thumbs folder 📻
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/48573.