ID: 28949 User updated by: vkary at web dot de Reported By: vkary at web dot de Status: Open Bug Type: GD related Operating System: WinXP & Linux PHP Version: 4.3.7 New Comment:
...and another difference: A few lines above, the variable "count" is initialized with "0" Previous Comments: ------------------------------------------------------------------------ [2004-07-03 11:58:53] vkary at web dot de I have found a difference between the PHP 4.3.2 and PHP 4.3.7 in the file "gd_topal.c" gd_topal.c, PHP 4.3.2, lines 733-742 ------------------------------------- #ifdef ORIGINAL_LIB_JPEG cinfo->colormap[0][icolor] = (JSAMPLE) ((c0total + (total >> 1)) / total); cinfo->colormap[1][icolor] = (JSAMPLE) ((c1total + (total >> 1)) / total); cinfo->colormap[2][icolor] = (JSAMPLE) ((c2total + (total >> 1)) / total); #else im->red[icolor] = (int) ((c0total + (total >> 1)) / total); im->green[icolor] = (int) ((c1total + (total >> 1)) / total); im->blue[icolor] = (int) ((c2total + (total >> 1)) / total); #endif } gd_topal.c, PHP 4.3.7, lines 733-748 ------------------------------------- #ifdef ORIGINAL_LIB_JPEG cinfo->colormap[0][icolor] = (JSAMPLE) ((c0total + (total >> 1)) / total); cinfo->colormap[1][icolor] = (JSAMPLE) ((c1total + (total >> 1)) / total); cinfo->colormap[2][icolor] = (JSAMPLE) ((c2total + (total >> 1)) / total); #else /* 2.0.16: Paul den Dulk found an occasion where total can be 0 */ if (count) { im->red[icolor] = (int) ((c0total + (total >> 1)) / total); im->green[icolor] = (int) ((c1total + (total >> 1)) / total); im->blue[icolor] = (int) ((c2total + (total >> 1)) / total); } else { im->red[icolor] = 255; im->green[icolor] = 255; im->blue[icolor] = 255; } #endif ------------------------------------------------------------------------ [2004-06-28 18:27:19] vkary at web dot de Description: ------------ When trying to reduce a true color image to a palette image with for example 16 or 32 colors, many colors are missing from the palette and filled with white color instead. Reproduce code: --------------- <?php $src_im = imagecreatefromjpeg ("ara.jpg"); imagetruecolortopalette ($src_im, false, 16); Header("Content-type: image/png"); imagepng($src_im); ?> Expected result: ---------------- The color palette should have exactly the number of colors specified in imagetruecolortopalette (16 for example) an the color reduced image should look like this:(created with PHP 4.3.2, GD-Lib 2.0.12) http://www.textilenetwork.de/php/ara16_4_3_2.png The color palette for the image above: http://www.textilenetwork.de/php/ara16_4_3_2_pal.png or for 32 colors: http://www.textilenetwork.de/php/ara32_4_3_2.png http://www.textilenetwork.de/php/ara32_4_3_2_pal.png Actual result: -------------- The images and color palettes with PHP 4.3.6: (& PHP 4.3.7) http://www.textilenetwork.de/php/ara16_4_3_6.png http://www.textilenetwork.de/php/ara16_4_3_6_pal.png http://www.textilenetwork.de/php/ara32_4_3_6.png http://www.textilenetwork.de/php/ara32_4_3_6_pal.png ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=28949&edit=1