Graphics Php

, string mode, int size
function img_resize($path2image,$path2thumb,$axis,$size)
{
$imageName = basename($path2image);
$thumbName = basename($path2thumb);
if (ereg("\.gif$",$img_name) || ereg("\.jpe?g",$img_name))
{
$djpeg = "/usr/bin/djpeg";
$cjpeg = "/usr/bin/cjpeg";
$pnmscale = "/usr/bin/pnmscale";
$giftopnm = "/usr/bin/giftopnm";
$ppmtogif = "/usr/bin/ppmtogif";
$ppmquant = "/usr/bin/ppmquant";
$imageAttributes = GetImageSize($path2image);
$imageWidth = $imageAttributes[0];
$imageHeight = $imageAttributes[1];
if ($imageWidth < $size && $imageHeight < $size)
{
@exec("cp $path2image $path2thumb");
chmod($path2thumb, 0666);
}
else
{
if ($axis == "h" || $axis == "a" && $imageHeight > $imageWidth)
{
switch ($imageAttributes[2])
{
case 1:
exec("$giftopnm $path2image | $pnmscale -height $size | $ppmquant 256
| $ppmtogif -interlace > $path2thumb");
chmod($path2thumb, 0666);
break;
case 2:
exec("$djpeg $path2image | $pnmscale -height $size | $cjpeg -outfile
$path2thumb");
chmod($path2thumb, 0666);
break;
case "":
return("");
break;
}
}
if ($axis == "w" || $axis == "a" && $imageWidth > $imageHeight)
{
switch ($imageAttributes[2])
{
case 1:
exec("$giftopnm $path2image | $pnmscale -width $size | $ppmquant 256
| $ppmtogif -interlace > $path2thumb");
chmod($path2thumb, 0666);
break;
case 2:
exec("$djpeg $path2image | $pnmscale -width $size | $cjpeg -outfile
$path2thumb");
chmod($path2thumb, 0666);
break;
case "":
return("");
break;
}
}
}
}
else
{
echo ''
.'Unable to complete Resize Function, The file being processed is not a
valid image file. Please use only .GIF or .JPG files'
.'
'
.'
'
."Hit your browser's back button to continue"
.'

';
}
}