color problems when resizing image with GD
| From: | Michael Hall | Date: | Thu, 29 Nov 2001 16:01:39 +0000 |
| Subject: | color problems when resizing image with GD | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-76048@lists.php.net to get a copy of this message | ||
We run on a Windows platform. If a client uploads an image to my script
that is too wide, I want to use GD to resize the image down to the proper
dimensions.
The problem I'm having is that the resized image drops huge chunks of the
color pallette, creating what is basically a monochromatic image.
Is there any way around this? Am I doing something wrong? I'm not very
familiar at all with the graphics part of things, so I'm hoping there's
something glarinly obvious that I'm missing.
The code follows.
$src_img =
ImageCreateFromJpeg("../images/property/property_".$id."tmp.jpg");
#[...]
$dst_img = ImageCreate ($new_w,$new_h);
ImageCopyResampled($dst_img,$src_img,0,0,0,0,$new_w,$new_h,ImageSX($src_img)
,ImageSY($src_img));
ImageJpeg($dst_img,"../images/property/property_".$id.".jpeg");
Michael Hall
Web Development Manager / Sr. Programmer
Prairie Fire Internet Technologies
mike@pfbiz.com
605.357.9700 ext. 14