Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2025-08-12 06:13:50

phiw13
Plugin Author
From: South-Western Japan
Registered: 2004-02-27
Posts: 3,440
Website

generated thumbnail images compression level with .webp images

I am always rather unhappily surprised with the size of the generated thumbnails when using .webp images – on average 30% larger than it should be. This happens both with the Textpattern generated thumbnails and those generated with the smd_thumbnail plugin.

I tried to find if Textpattern or the plugin somewhere set the compression level by I got nowhere. Is there a way to improve that.

(recent versions of PHP, Textpattern 4.9dev, GD in use)


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg

Offline

#2 2025-08-12 09:16:34

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,862
Website GitHub

Re: generated thumbnail images compression level with .webp images

Leave this with me.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Online

#3 2025-08-12 10:38:41

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,862
Website GitHub

Re: generated thumbnail images compression level with .webp images

This commit introduces the overridable TEXTPATTERN_THUMB_QUALITY constant. Add something like the following to your config.php:

define('TEXTPATTERN_THUMB_QUALITY', 60);

to lower the quality from its default value of 80 percent. The quality value is applied to JPG, WEBP and AVIF thumbnails.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Online

#4 2025-08-12 11:37:19

phiw13
Plugin Author
From: South-Western Japan
Registered: 2004-02-27
Posts: 3,440
Website

Re: generated thumbnail images compression level with .webp images

Interesting, will check it out tomorrow.


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg

Offline

#5 Yesterday 01:52:12

phiw13
Plugin Author
From: South-Western Japan
Registered: 2004-02-27
Posts: 3,440
Website

Re: generated thumbnail images compression level with .webp images

Bloke wrote #340123:

This commit introduces the overridable TEXTPATTERN_THUMB_QUALITY constant. Add something like the following to your config.php:

define('TEXTPATTERN_THUMB_QUALITY', 60);...

to lower the quality from its default value of 80 percent. The quality value is applied to JPG, WEBP and AVIF thumbnails.

Sadly it doesn’t seem to change much to the file size. For a webp image I set it to 50 to match the setting used in Acorn. Recreating the 800*450px thumbnail (from a 1600*900px source image), I get a 12% reduction only (expected: 25%). Testing with a jpg with a setting at 70 again to match Acorn settings shows a slightly better result: a 10% file size reduction compared to the originally generated thumbnail.

Testing with the same webp image but with smd_thumbnail enabled and the profile configured to match shows better results (~20% less).

For the jpeg files it is still an improvement (the user/owner of the site most always deals with jpeg files).


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg

Offline

#6 Yesterday 08:32:40

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,862
Website GitHub

Re: generated thumbnail images compression level with .webp images

That’ll probably be down to GD then. We pass the quality setting to PHP in its relevant function signature and the rest is out of our hands.

Keep this feature? Revert it?


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Online

#7 Yesterday 09:36:06

phiw13
Plugin Author
From: South-Western Japan
Registered: 2004-02-27
Posts: 3,440
Website

Re: generated thumbnail images compression level with .webp images

Bloke wrote #340208:

That’ll probably be down to GD then. We pass the quality setting to PHP in its relevant function signature and the rest is out of our hands.

Keep this feature? Revert it?

I still see a win for those jpeg with some 10~15% fat reduction compared to the default (using 70 instead of the default, 80).


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg

Offline

#8 Yesterday 09:43:03

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,862
Website GitHub

Re: generated thumbnail images compression level with .webp images

Fine by me. It stays :)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Online

Board footer

Powered by FluxBB