note 44803 added to function.imagetruecolortopalette

From: Date: Tue, 17 Aug 2004 05:58:26 +0000
Subject: note 44803 added to function.imagetruecolortopalette
Groups: php.notes 
Request: Send a blank email to php-notes+get-74789@lists.php.net to get a copy of this message
Sometimes this function gives ugly/dull colors (especially when ncolors < 256). Here is a replacement that uses a temporary image and ImageColorMatch() to match the colors more accurately. It might be a hair slower, but the file size ends up the same: <?php function ImageTrueColorToPalette2( $image, $dither, $ncolors ) { $width = imagesx( $image ); $height = imagesy( $image ); $colors_handle = ImageCreateTrueColor( $width, $height ); ImageCopyMerge( $colors_handle, $image, 0, 0, 0, 0, $width, $height, 100 ); ImageTrueColorToPalette( $image, $dither, $ncolors ); ImageColorMatch( $colors_handle, $image ); ImageDestroy( $colors_handle ); } ?> ---- Manual Page -- http://www.php.net/manual/en/function.imagetruecolortopalette.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+44803 Delete -- http://master.php.net/manage/user-notes.php?action=delete+44803&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+44803&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#74789) next »