PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Images » Image_Transform » Bug #3040

If Clause within the resize function / GD Driver not satistied.

Details

Submitted2004-12-27 18:33 UTC
Fromn dot leutner at all2e dot com
Assignedjausions
StatusClosed
PackageImage_Transform
PHP Version4.3.10
OSWin32
Roadmaps(Not assigned)

Comments

[2004-12-27 18:33 UTC] n dot leutner at all2e dot com

Description:
------------
If Clause within the resize function / GD Driver not satistied.
I`m using GD bundled (2.0.28 compatible) and had to change that function.

Reproduce code:
---------------
function _resize($new_x, $new_y) {
if ($this->resized === true) {
return PEAR::raiseError('You have already resized the image without saving it. Your previous resizing will be overwritten', null, PEAR_ERROR_TRIGGER, E_USER_NOTICE);
}
//if (function_exists('ImageCreateTrueColor') && @ImageCreateTrueColor()) {
if (function_exists('ImageCreateTrueColor')) {
$new_img =ImageCreateTrueColor($new_x,$new_y);
} else {
$new_img =ImageCreate($new_x,$new_y);
}
//if (function_exists('ImageCopyResampled') && @ImageCopyResampled()) {
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);
}
$this->old_image = $this->imageHandle;
$this->imageHandle = $new_img;
$this->resized = true;

$this->new_x = $new_x;
$this->new_y = $new_y;
return true;
}

Expected result:
----------------
If you change the clauses from
if (function_exists('ImageCreateTrueColor') && @ImageCreateTrueColor())
to
if (function_exists('ImageCreateTrueColor'))
the resize function works fine.

[2005-03-14 05:42 UTC] pear at tannesen dot com

I also had problems with this section of the _resize method in the Driver/GD.php file. The method did not correctly detect the existence of the imagecreatetruecolor method. When I resized a jpeg, the colors were very distorted. I changed line 187 from

if (function_exists('ImageCreateTrueColor') && @ImageCreateTrueColor()) {

to

if (function_exists('imagecreatetruecolor') && @ImageCreateTrueColor(1,1)) {

The if statement correctly returned true for the first half, but incorrectly returned false on the second half.

PHP Version 4.3.10

gd
GD Support enabled
GD Version bundled (2.0.28 compatible)
FreeType Support enabled
FreeType Linkage with freetype
T1Lib Support enabled
GIF Read Support enabled
GIF Create Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled
XBM Support enabled