Possible bug in Image_Transform and/or GD2?
| From: | Markus Wolff | Date: | Wed, 15 Jan 2003 10:58:38 +0000 |
| Subject: | Possible bug in Image_Transform and/or GD2? | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-12462@lists.php.net to get a copy of this message | ||
Hi there,
we might have encountered a bug in Image_Transform´s GD driver. We
have created a file upload form that will resize incoming files using
Image_Transform. The GDlib we use is the GD2.dll coming with PHP 4.3.0.
If you upload a truecolor JPEG and Image_Transform_Driver_GD::_resize
is called, the colors from the JPEG disappear - the result is a
greyscale image (sometimes even the overall brightness disappears,
resulting in a nearly black image).
The solution that we´ve found is to change the check for truecolor
support in Image_Transform_Driver_GD. From line 331 on, it originally
says:
if(@ImageCreateTrueColor()){
$new_img =ImageCreateTrueColor($new_x,$new_y);
} else {
$new_img =ImageCreate($new_x,$new_y);
}
if(@ImageCopyResampled()){
ImageCopyResampled($new_img, $this->imageHandle, 0, 0, 0, 0, $new_x, $new_y, $this->img_x,
$this->img_y);
} else {
ImageCopyResized($new_img, $this->imageHandle, 0, 0, 0, 0, $new_x, $new_y, $this->img_x,
$this->img_y);
}
We changed this to:
if(function_exists('ImageCreateTrueColor')){
$new_img =ImageCreateTrueColor($new_x,$new_y);
} else {
$new_img =ImageCreate($new_x,$new_y);
}
if(function_exists('ImageCopyResampled')){
ImageCopyResampled($new_img, $this->imageHandle, 0, 0, 0, 0, $new_x, $new_y, $this->img_x,
$this->img_y);
} else {
ImageCopyResized($new_img, $this->imageHandle, 0, 0, 0, 0, $new_x, $new_y, $this->img_x,
$this->img_y);
}
..and then it worked! Maybe calling the functions without the
neccessary parameters somehow messes with the image data currently in
the buffer? Shouldn´t be this way, but I have no other explanation...
Can anyone reproduce this?
Regards,
Markus
--
*21st Media* | Consulting, Konzeption, Produktion für die Bereiche:
Markus Wolff | Internet, Intranet, eCommerce, Content Management,
Hamburg,Germany | Softwareentwicklung, 3D-Animation, Videostreaming
http://21st.de | Tel. [+49](0)40/6887949-0, Fax: [+49](0)40/6887949-1