note 18150 deleted from function.imagecolorallocate by danbrown
| From: | danbrown@php.net | Date: | Fri, 24 Apr 2009 12:53:04 +0000 |
| Subject: | note 18150 deleted from function.imagecolorallocate by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-153677@lists.php.net to get a copy of this message | ||
Note Submitter: doiveo at hotmail dot nospam
----
This will help anyone trying to control font colors in a JPEG. You have to create a temporary image
first, allocate the colors then merge the images before it works. Go figure.
$im_size = GetImageSize ( "MySource.jpg" );
$imageWidth = $im_size[0];
$imageHeight = $im_size[1];
$im = imageCreate( $imageWidth, $imageHeight );
// - or with GD 2+ -
// $im = imageCreateTrueColor( $imageWidth, $imageHeight );
// do all your color allocations here
$font_color_black = ImageColorAllocate( $im, 0,0,0);
$im2 = ImageCreateFromJPEG("MySource.jpg");
ImageCopy ($im,$im2,0,0,0,0, $imageWidth, $imageHeight);
ImageDestroy ($im2);
...finish as you please using the $im var.