PHP is telling me that I need GD 2.0 or later. This is on a newly installed
mandrake 9 distro. Could this be a configuration issue? or do I need to
figure out how to update GD?
I get these errors:
Warning: imagecreatetruecolor(): requires GD 2.0 or later in
/var/www/html/golgo13/includes/img.class.php on line 55
Warning: imagecopyresampled(): requires GD 2.0 or later in
/var/www/html/golgo13/includes/img.class.php on line 56
Warning: imagedestroy(): supplied argument is not a valid Image resource in
/var/www/html/golgo13/includes/img.class.php on line 73
Warning: imagedestroy(): supplied argument is not a valid Image resource in
/var/www/html/golgo13/includes/img.class.php on line 74
When I run this script:
$image = new image;
$image->max_size = 300;
$image->upload($data, $data_type);
Here are the relevent class functions:
function load_gd()
{// Checks to see if GD has been loaded. If not it loads the dll/so file
if (!extension_loaded('gd'))
{
if (!dl('gd.so'))
{
if (!dl('gd.dll'))
{
exit;
}
}
}
}
function resize()
{// Resizes Image to be within maximum size, could be expanded to have
seperate width and height values.
$this->load_gd();// Check that gd is loaded and availible.
$size = GetImageSize($this->temp_loc);
$width = $size[0];
$height = $size[1];
if(($width > $this->max_size) || ($height > $this->max_size))
{
switch ($pictype)
{
case "image/gif";
$this->src_img = ImageCreateFromGif($picdata);
break;
case "image/jpeg";
$this->src_img = ImageCreateFromJpeg($picdata);
break;
case "image/png";
$this->src_img = ImageCreateFromPng($picdata);
break;
default:
$mimeName = "Unknown image type, failed";
}
$orig_x = $width;
$orig_y = $height;
$new_y = $this->max_size;
$new_x = $orig_x/($orig_y/$this->max_size);
$dst_img = ImageCreateTrueColor($new_x,$new_y);
ImageCopyResampled($dst_img, $this->temp_loc, 0, 0, 0, 0, $new_x,
$new_y, $orig_x, $orig_y);
switch ($pictype)
{
case "image/gif";
$this->src_img = imagepng ($dst_img);
break;
case "image/jpeg";
$this->src_img = imagejpeg($dst_img);
break;
case "image/png";
$this->src_img = imagepng ($dst_img);
break;
default:
$mimeName = "Unknown image type, failed";
}
$this->picdata = $dst_img;
ImageDestroy($src_img);
ImageDestroy($dst_img);
}
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php