diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2016-09-03 17:01:56 +0200 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2016-09-03 17:48:03 +0200 |
commit | 24b4550fa808bec2bfcf139ee109cb145a172412 (patch) | |
tree | a8531ad29beee902b3e33da660e9f5f585e54384 /src/gd_topal.c | |
parent | b53cebfab8e7e37d86f978c6a85bd16fdd96afa5 (diff) | |
download | libgd-24b4550fa808bec2bfcf139ee109cb145a172412.tar.gz |
Fix PHP bug #67325: imagetruecolortopalette: white is duplicated in palette
gdImageTrueColorToPalette() is sometimes wasteful by putting multiple white
color entries into the palette. This is caused by an obvious typo, where
to avoid a division by zero when `total` is zero, `count` is checked instead
of `total`.
We fix this issue, to improve the quality of the color quantization.
Diffstat (limited to 'src/gd_topal.c')
-rw-r--r-- | src/gd_topal.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/gd_topal.c b/src/gd_topal.c index 7ff835a..c732ba1 100644 --- a/src/gd_topal.c +++ b/src/gd_topal.c @@ -659,7 +659,7 @@ compute_color (gdImagePtr oim, gdImagePtr nim, my_cquantize_ptr cquantize, } /* 2.0.16: Paul den Dulk found an occasion where total can be 0 */ - if (count) { + if (total) { nim->red[icolor] = (int) ((c0total + (total >> 1)) / total); nim->green[icolor] = (int) ((c1total + (total >> 1)) / total); nim->blue[icolor] = (int) ((c2total + (total >> 1)) / total); |