bug PR-6.2-dev Pending

User tests: Successful: Unsuccessful:

avatar ryandemmer
ryandemmer
5 Oct 2026
  • I read the Generative AI policy and my contribution is either not created with the help of AI or is compatible with the policy and GNU/GPL 2 or later.

Summary of Changes

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.

Testing Instructions

Enable Create Thumbnails in Filesystem - Local, upload a 1000×2 image (or 2×1000), and open that folder in the Media Manager.

Actual result BEFORE applying this Pull Request

The ValueError is thrown and the folder doesn't list, e.g.

imagecreatetruecolor(): Argument #2 ($height) must be greater than 0

Expected result AFTER applying this Pull Request

The folder lists and a thumbnail of 200×1 is generated for the image.

Link to documentations

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

avatar ryandemmer ryandemmer - open - 5 Oct 2026
avatar ryandemmer ryandemmer - change - 5 Oct 2026
Status New ⇒ Pending
avatar joomla-cms-bot joomla-cms-bot - change - 5 Oct 2026
Category ⇒ Libraries
avatar ryandemmer ryandemmer - change - 5 Oct 2026
Title
…
Image: prevent zero width or height when resizing with extreme aspect ratios
[AI] Image: prevent zero width or height when resizing with extreme aspect ratios
avatar ryandemmer ryandemmer - edited - 5 Oct 2026
avatar ryandemmer ryandemmer - change - 5 Oct 2026
The description was changed
avatar ryandemmer ryandemmer - edited - 5 Oct 2026
avatar ryandemmer ryandemmer - change - 5 Oct 2026
Labels Added: PR-5.4-dev
avatar exlemor exlemor - test_item - 29 Oct 2026 - Tested successfully
avatar exlemor
exlemor - comment - 29 Oct 2026

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.
avatar exlemor
exlemor - comment - 29 Oct 2026

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.
avatar richard67 richard67 - change - 31 Oct 2026
Title
…
[AI] Image: prevent zero width or height when resizing with extreme aspect ratios
[6.2] [AI] Image: prevent zero width or height when resizing with extreme aspect ratios
avatar richard67 richard67 - edited - 31 Oct 2026
avatar richard67
richard67 - comment - 31 Oct 2026

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.

avatar richard67 richard67 - change - 31 Oct 2026
Labels Added: bug PR-6.2-dev
Removed: PR-5.4-dev
avatar richard67 richard67 - alter_testresult - 31 Oct 2026 - exlemor: Tested successfully

Add a Comment

Login with GitHub to post a comment