note 33319 deleted from function.imagecopyresized by aidan
| From: | aidan@php.net | Date: | Mon, 04 Oct 2004 09:39:31 +0000 |
| Subject: | note 33319 deleted from function.imagecopyresized by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-77914@lists.php.net to get a copy of this message | ||
Note Submitter: jostein at retoid dot com
----
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 :)