[wp-trac] [WordPress Trac] #63448: Image quality significantly degrades for resized PNGs with transparency in WordPress 6.8.1
WordPress Trac
noreply at wordpress.org
Fri May 16 09:27:13 UTC 2025
#63448: Image quality significantly degrades for resized PNGs with transparency in
WordPress 6.8.1
--------------------------+---------------------
Reporter: elvismdev | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 6.8.2
Component: Media | Version: 6.8
Severity: major | Resolution:
Keywords: has-patch | Focuses:
--------------------------+---------------------
Comment (by siliconforks):
The patch in [https://github.com/WordPress/wordpress-develop/pull/8810 PR
#8810] doesn't really seem to fix the fundamental issue here...
I think fundamental problem is that [59589] seems to be assuming that if
`getImageDepth()` returns <= 8, the image must be using <= 256 colors (so
it is either using indexed color or it can be converted to indexed color)
- but I don't think this is correct.
ImageMagick appears to use the term "depth" to refer to the depth of an
image channel rather than the depth of the entire image. See for example
https://github.com/ImageMagick/ImageMagick/blob/main/MagickCore/attribute.c
where it states that "GetImageDepth() returns the depth of a particular
image channel." (Note that the C function `GetImageDepth` is not the same
thing as the PHP function `getImageDepth` but I suspect they are both
using the same definition of "depth".)
Similarly the ImageMagick `identify` command considers the file `vivid-
green-bird-sample-original.png` to have "Depth: 8-bit":
{{{
$ identify -verbose -unique vivid-green-bird-sample-original.png
Image:
Filename: vivid-green-bird-sample-original.png
Format: PNG (Portable Network Graphics)
Mime type: image/png
...
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
alpha: 8-bit
...
Colors: 830043
}}}
So the image has more than 800,000 colors but ImageMagick still considers
the "depth" to be 8 bits (because the depth of the red channel, the green
channel, the blue channel, and the alpha channel are each 8 bits).
You can get the same result with a simple PHP program:
{{{#!php
<?php
$image = new Imagick('vivid-green-bird-sample-original.png');
$depth = $image->getImageDepth();
echo 'depth = ' . $depth . "\n";
$colors = $image->getImageColors();
echo 'colors = ' . $colors . "\n";
}}}
This will display:
{{{
depth = 8
colors = 830043
}}}
So I think [59589] really needs to be reworked to not use `getImageDepth`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63448#comment:11>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list