image_transform errors with GD2
| From: | ThE PhP_KiD | Date: | Mon, 21 Apr 2003 18:11:00 +0000 |
| Subject: | image_transform errors with GD2 | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-4980@lists.php.net to get a copy of this message | ||
Hi,
I'm trying "image_transform" module with
GD, and it works very well.
But when I try to work with GD2, the class seems
don't detect that GD2 is loaded, and "image_transform"
try to work with GD1 functions.
To fix it, (almost for me), I've changed
function "_resize", and add a new atributte "GD2"
(see below).
But I've found another bug, that I can't fix.
When you work with GD2 and under windows, you get
a error:
"Could not find/open font in c:\php\pear\Image\Transform\Driver\GD.php on line 135"
At line 135 you have:
"ImageTTFText($this->imageHandle, $size, $angle, $x, $y, $c, $font, $text);"
I've trying to change $font with:
$font="c://windows/fonts/arial.ttf";
$font="c:\\windows\\fonts\\arial.ttf";
$font="arial";
$font="arial.ttf";
and, again and again fails with same error.
Also, I've tried to copy font to $DOCUMENT_ROOT location, and fails too.
------------------------------------------------------
Class Image_Transform_Driver_GD extends Image_Transform
{
// .... some vars
var $GD2 = false;
..
}
/**
* Active GD 2
*/
function SetGD2($val=true) {
$this->GD2=$val;
}
///////
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($this->GD2){ /// <--- This is line I've changed
// echo "working with GD2!";
$new_img =ImageCreateTrueColor($new_x,$new_y);
} else {
// echo "working with GD1!";
$new_img =ImageCreate($new_x,$new_y);
}
if($this->GD2){ /// <--- This is another line I've changed
// echo "working with GD2!";
ImageCopyResampled($new_img, $this->imageHandle, 0, 0, 0, 0,
$new_x, $new_y, $this->img_x, $this->img_y);
} else {
// echo "working with GD1!";
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;
}