Add some png and jpg images to the /images folder
Go to the Filesystem local plugin and enable cache
Compare the file sizes in /images and /media/cache/com_media/thumbs
ALL the files in the cache have been reduced in both dimension and filesize
All the file dimensions have been reduced but the filesize has in some cases increased
I have prepared a zip containing 5 images so that we can compare with the same image
filename | original filesize kb | cache filesize kb | reduced |
---|---|---|---|
image1.png | 44.05 | 105.85 | ❌ |
image2.png | 452.83 | 75.3 | ✔️ |
image3.png | 30.47 | 93.39 | ❌ |
image4.jpg | 250.94 | 27.79 | ✔️ |
image5.jpg | 114.55 | 26 | ✔️ |
image6.jpg | 260.38 | 34.84 | ✔️ |
I appreciate that the original images might have been saved with different compression algorithms and ratios. These are just a random selection of images on my hdd.
In all cases the file has been reduced in dimensions so at the very least it would be reasonable to assume that its a bug if the reduced file is double the storage size of the original
Labels |
Added:
No Code Attached Yet
|
How can it be expected to reduce the dimensions of a png and yet the filesize increases by 300%
That completely defeats the objective of the thumbnail creation
/me doesnt understand how it is not a bug - please can you explain
It is PHP side (PHP GD), not Joomla.
All we can do is try to set "quality" https://www.php.net/manual/en/function.imagepng.php different from default.
How can it be expected to reduce the dimensions of a png and yet the filesize increases by 300%
Depend from amount of detail the image have, it can happen for PNG in any application, not only PHP
As the purpose of creating the thumbnail is to crerate a fast loading version of the image and this thumbnail will only be displayed in the media manager why not always set the compression to the maximum.
Otherwise any png that has been optimised before uploading to joomla will generate a larger file when resized
The code exists already to select the image quality. Its just not used at all so the compression defaults to 0 :(
It a bit tricky, PNG have a range -1 ... 9, JPG -1 .. 100.
Need an extra logic, extra code, but should be possible.
Someone can try.
I just can't say how much it will really help. For cases when User upload "optimised PNG", the thumbnail still may be bigger after PHP processing.
As the purpose of creating the thumbnail is to crerate a fast loading version of the image
Well, it is more for really large (resolution) images , for images with small resolutions it probably irrelevant
I did a quick manual try with PNG set to 9 and the difference was amazing.
Our code supports different settings for jpg and png compression/quality it's just not being used for the thumbs
@brianteeman although the Image class supports different compression ratios the functionality for the thumbnails doesn't expose it:
joomla-cms/libraries/src/Image/Image.php
Line 319 in 45adb61
I did the implementation for the thumbnails so I guess this is my fault, if you need to blame somebody
not interested in blame - just interested in making the thumbs functionality work as intended. I am certain you didnt intent to make the thumbnails bigger than the original ;)
If you still have the test site available could you try adding:
$image->setThumbnailGenerate(false);
Should do the trick
surely that just disabled the creation of thumbnails ??
surely that just disabled the creation of thumbnails ??
The docs say that this controls the quality:
joomla-cms/libraries/src/Image/Image.php
Lines 1124 to 1133 in 45adb61
my bad - i will test that soon
all that does is to create reall bad quality thumbnails that are the same filesize as the good ones
filename | original filesize kb | cache filesize kb | cache filesize after |
---|---|---|---|
image1.png | 44.05 | 105.85 | 1-5.85 |
image2.png | 452.83 | 75.3 | 75.3 |
image3.png | 30.47 | 93.39 | 93.39 |
image4.jpg | 250.94 | 27.79 | 31.34 |
image5.jpg | 114.55 | 26 | 30.48 |
image6.jpg | 260.38 | 34.84 | 42.02 |
@brianteeman check #43282
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2024-04-15 17:04:07 |
Closed_By | ⇒ | alikon |
My concern while testing this feature was whether Joomla would keep thumbnails of non-existent images inside the "media/cache/com_media/thumbs/images" folder. So I thought clearing the cache via System > Clear Cache is a good way to clear all the thumbnails, so they reproduce again when I visit Media Manager. Unfortunately it seems it doesn't. Even if I disable this feature in the "FileSystem - Local" plugin, they remain there.
a) Shouldn't Clear Cache clear the thumbnails?
b) Shouldn't disabling this feature via the "FileSystem - Local" extension also delete these thumbnails, regardless of Clear Cache?
@impressionestudio Can you open a new Issue for your comment and link also to this Issue? Comments on closed issues or pull request get less attention.
The clearing of cache should be implemented but I don’t like the idea of automatically removing the cache if the option is disabled…
It kind of expected, for PNG.
It not a bug.
I would say: it is how algorithm work for PNG.
In theory we can try to play with higher compression, but still, in some cases PNG can be bigger.