note 33319 added to function.imagecopyresized

From: Date: Sun, 22 Jun 2003 23:00:21 +0000
Subject: note 33319 added to function.imagecopyresized
Groups: php.notes 
Request: Send a blank email to php-notes+get-50821@lists.php.net to get a copy of this message
Here's a suggestion to the color problem with imagecopyresized()... When imagecopyresized() runs, it allocates the first colors that it passes by. You might get a very blue picture if the top of the picture is a sky. The trick is to allocate colors before running imagecopyresized(). Grayscale works perfectly by doing this: <? $source = imagecreatefromjpeg("sky.jpg"); $dest = imagecreate(100, 100); for($i=0; $i<256; $i++) imagecolorallocate($dest, $i, $i, $i); imagecopyresized($dest, $source, 0, 0, 0, 0, imagesx($source), imagesy($source)); imagejpeg($dest); ?> I accidently did $i+=4 instead of $i++. The result was a good range of colors. You might wanna try that also :) ---- Manual Page -- http://www.php.net/manual/en/function.imagecopyresized.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33319 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33319&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33319&report=yes

« previous php.notes (#50821) next »