John Nichel wrote:
I'm diving into the gd functions for the first time, and I'm having a
problem creating a white background for an image when using
imagecreatetruecolor(). The manual says that this function will create
a _black_ image, but looking at imagecolorallocate() it says that the
first call to this function fills the background color, and they have
examples like this...
$im = imagecreatetruecolor('example.jpg');
// sets background to red
$background = imagecolorallocate($im, 255, 0, 0);
So, thinking that I could make a this with a white background, I did
this...
$im = imagecreatetruecolor ( 140, 140 );
$bg = imagecolorallocate ( $im, 255, 255, 255 );
$orgimg = imagecreatefromjpeg ( $image_data['image'] );
imagecopyresampled ( $im, $orgimg, $thumb_x_offset, $thumb_y_offset, 0,
0, $new_thumb_x, $new_thumb_y, $image_data['image_x'],
$image_data['image_y'] );
imagejpeg ( $im, $image_paths['thumbs'] . $file_name );
And that creates the image with the right sizes and positions, but the
background is black. Is there something wrong in my code, or is the
manual wrong on the imagecolorallocate() function? TIA.
The manual is _my_ friend....at least the comments in the manual are. I
had to use the imagefill() function...
$im = imagecreatetruecolor ( 140, 140 );
$bg = imagecolorallocate ( $im, 255, 255, 255 );
imagefill ( $im, 0, 0, $bg );
--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
john@xxxxxxxxxxxx
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php