White background with imagecreatetruecolor()

From: Date: Tue, 18 Oct 2005 19:21:24 +0000
Subject: White background with imagecreatetruecolor()
Groups: php.general 
Request: Send a blank email to php-general+get-224300@lists.php.net to get a copy of this message
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. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 john@kegworks.com

« previous php.general (#224300) next »