Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.4.15]: Quality setting does not work for transforms of png images #13493

Open
thupsi opened this issue Aug 1, 2023 · 6 comments
Open

[4.4.15]: Quality setting does not work for transforms of png images #13493

thupsi opened this issue Aug 1, 2023 · 6 comments

Comments

@thupsi
Copy link

thupsi commented Aug 1, 2023

What happened?

Description

Transforms of png images to any format always result in the same file size, irrespective of the quality setting.

The file size is large, so I assume the output quality is always maximum.

This happens both on local (latest DDEV) and on a server provisioned with Ploi with all the latest updates.

ImageMagick version from system report: Imagick 3.7.0 (ImageMagick 6.9.11-60)

Steps to reproduce

  1. Upload a png image file to any asset folder.
  2. Output a transform of this asset in a template, either with a named transform or with a template defined transform, with a quality of 100.
  3. Take note of the file size.
  4. Change the transform quality setting to a lower quality.
  5. Check the new file size.

Expected behavior

The file size should be lower, due to lower quality

Actual behavior

The file size remains exactly the same, no matter how low the quality setting.

Craft CMS version

4.4.15

PHP version

8.2.8

Operating system and version

No response

Database type and version

No response

Image driver and version

Imagick 3.7.0 (ImageMagick 6.9.11-60)

Installed plugins and versions

@brandonkelly
Copy link
Member

I’m able to reproduce this, but I don’t believe it’s a bug.

PNG images don’t technically have a quality; they have a compression level. I verified that different quality values will result in different values(*) getting passed to Imagick::setImageCompressionQuality(), but I don’t know enough about the inner workings of ImageMagick to know why that would still result in the same filesize (at least for some PNGs).

*worth noting that PNG compression levels get normalized to an integer between 0 and 9. E.g. a quality of 82 will end up with a compression level of 2. So subtle changes in quality will definitely have no effect.

@thupsi
Copy link
Author

thupsi commented Aug 3, 2023

Even so, when the transform is converting the image to another file type such as webp, the quality setting should have an effect! In this case it doesn't. Also, I think I tried at somepoint to transform from png with transparency to jpeg and the resulting image retained the transparency. It almost seems like the images are not converted but kept as png and only the file extension changes.

@thupsi
Copy link
Author

thupsi commented Aug 3, 2023

Also FWIW, I'm not talking about subtle changes. Even going from 100 to 10 quality has no effect.

@brandonkelly
Copy link
Member

Looks like you might be right. Looking into it…

brandonkelly added a commit that referenced this issue Aug 4, 2023
@brandonkelly
Copy link
Member

Fixed transform format swapping for the next release, however that’s unrelated to PNG image compression, which is still not seeming to have any effect.

@brandonkelly
Copy link
Member

Craft 4.4.17 is out with a fix for format swapping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants