Imagick / imagick

🌈 The Imagick PHP extension 🌈
http://pecl.php.net/imagick
Other
548 stars 138 forks source link

Shadow-like line&row compression artefacts when saving to webp #665

Open michaylov opened 7 months ago

michaylov commented 7 months ago

Hello, guys,

I have stumbled upon a really strange issue when compressing webp images - shadow-like artefact or "bleeding" columns and rows. This happens only with certain images - uniform background and an object in the center. When compressing those to webp, the strange "shadows" often appear on the right and below the image. It is rarely noticeable with most colours though.

Original image (PNG, uniform background & object in the center): image

After compressing with imagick to webp, the artefacts appear: image

The same image with "bumped" contrast for easier recognition: image

No special settings were used in compression:

$im = new Imagick();
$im->readImage('bullseye_yellow_bg.png');
$im->setImageCompressionQuality(70);
$im->writeImage('b.webp');

I considered libwebp but was unable to reproduce with any settings. Also, no luck with imagemagick's cli tool convert. This problem happens with the x86 version of imagemagick and not aarch64.

Any help would be appreciated.

Danack commented 7 months ago

Hmm.

Also, no luck with imagemagick's cli tool convert.

Ugh.

I considered libwebp but was unable to reproduce with any settings.

Also, ugh.

You're already doing the things I would normally suggest.

Imagick is a really thin wrapper around ImageMagick, so it's unlikely the Imagick code is doing anything 'wrong', it's just that a particular set of circumstances results in an issue, that doesn't show itself otherwise.

This problem happens with the x86 version of imagemagick and not aarch64.

Can you say the exact versions of libwebp you're using on each of those platforms? https://www.google.com/search?q=linux+show+library+version

About the only useful thing I can suggest to try, is to run your program through valgrind e.g.

'valgrind php test.php'

And see if that shows any problem, as very occasionally there are things shown by that.

Please can you say what you're doing to adjust the contrast? It does make it easier to see the issue, but I'm having reproducing that effect.

The only people who are really going to be able to solve the issue, is going to be the people who maintain libwebp, which appears to have a project page here: https://github.com/webmproject/libwebp?tab=readme-ov-file

Danack commented 7 months ago

Hello, guys,

Just for the record, it's just one person.

Somewhat dispassionately, even if not surprisingly, it's very rare for any users of the project to provide help to each other, unless those people share the same problem.