JPEG quality not applied to PNGs which end up saved as JPGs

Created on 16 April 2020, almost 5 years ago
Updated 10 October 2024, 6 months ago

I have an image style called "medium" (configurable at /admin/config/media/image-styles/manage/medium) which contains a "Convert" effect as a last step, converting the image to JPG. So, for input /sites/default/files/images/foo.png I get a medium thumbnail at /sites/default/styles/medium/public/images/foo.png.jpg.

At /admin/config/media/image-toolkit I've selected the Imagick toolkit.

The problem is that the JPEG quality configured is not applied for PNG images which end up as JPG as explained above. It's only being applied to JPG source images.

One of the reasons may relate to the fact that ImagickToolkit.php on line 203 checks for $image_format but it should check the resulting image format which can be found at $destination:

    // Only compress JPEG files because other filetypes will increase in filesize
    if (isset($image_format) && in_array($image_format, ['JPEG', 'JPG', 'JPE'])) {
🐛 Bug report
Status

Closed: cannot reproduce

Version

1.0

Component

Code

Created by

🇬🇷Greece ioannis.cherouvim

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024