Hi,
I am working on a function to resize both gif's and jpg's and i seem to be getting an error on the following line:
if (imagegif($DEST_IMAGE,$outputSource))
here is the entire code:
//PURPOSE: creates a resized image in the same directory that the images source is in
//FIELDS: $imageSource - Location of image to be resized
// $width - Width of output picture
// $height - Height of output picture
// $outputSource - Name to call file
//EXAMPLE CODE: Client Login V1.0 - status.php
//KEYWORD: images, resize, resize images, jpg, create
function createResizedImage($imageSource,$width,$height,$outputSource)
{
//get the pictures properties
$imageProperties1 = getimagesize($imageSource);
$backupFile = "";
if ($imageProperties1[2] == 1)
{
//create name for backup file
$backupFile = $outputSource . "_backup.jpg";
}
else if ($imageProperties1[2] == 2)
{
//create name for backup file
$backupFile = $outputSource . "_backup.gif";
}
//copy input file to location of backup file
copy($imageSource,$backupFile);
//get the pictures properties
$imageProperties = getimagesize($backupFile);
//gif code
if ($imageProperties[2] == 1)
{
$srcImage = ImageCreateFromGIF($backupFile);
$SRC_X = ImageSX($srcImage);
$SRC_Y = ImageSY($srcImage);
if (($height == "0") && ($width == "0"))
{
return(0);
}
else if($height == "0")
{
$SCALEX = $width/($SRC_X-1);
$height = $SRC_Y*$SCALEX;
}
elseif ($width == "0")
{
$SCALEY = $height/($SRC_Y-1);
$width = $SRC_X*$SCALEY;
}
$width = (int)($width);
$height = (int)($height);
$DEST_IMAGE = imagecreatetruecolor($width, $height);
unlink($backupFile);
if (!imagecopyresized($DEST_IMAGE, $srcImage, 0, 0, 0, 0, $width, $height, $SRC_X, $SRC_Y))
{
imagedestroy($srcImage);
imagedestroy($DEST_IMAGE);
return(0);
}
else
{
imagedestroy($srcImage);
if (imagegif($DEST_IMAGE,$outputSource))
{
imagedestroy($DEST_IMAGE);
return(1);
}
imagedestroy($DEST_IMAGE);
}
}
//jpeg code
else if ($imageProperties[2] == 2)
{
$srcImage = ImageCreateFromJPEG($backupFile);
$SRC_X = ImageSX($srcImage);
$SRC_Y = ImageSY($srcImage);
if (($height == "0") && ($width == "0"))
{
return(0);
}
else if($height == "0")
{
$SCALEX = $width/($SRC_X-1);
$height = $SRC_Y*$SCALEX;
}
elseif ($width == "0")
{
$SCALEY = $height/($SRC_Y-1);
$width = $SRC_X*$SCALEY;
}
$width = (int)($width);
$height = (int)($height);
$DEST_IMAGE = imagecreatetruecolor($width, $height);
unlink($backupFile);
if (!imagecopyresized($DEST_IMAGE, $srcImage, 0, 0, 0, 0, $width, $height, $SRC_X, $SRC_Y))
{
imagedestroy($srcImage);
imagedestroy($DEST_IMAGE);
return(0);
}
else
{
imagedestroy($srcImage);
if (imagejpeg($DEST_IMAGE,$outputSource))
{
imagedestroy($DEST_IMAGE);
return(1);
}
imagedestroy($DEST_IMAGE);
}
}
return(0);
}
can anyone tell me why its giving me the following error?
Call to undefined function: imagegif()
Im running: PHP 4.3.3