When I try the below code, I get the following error:
Warning: imagesx(): supplied argument is not a valid Image resource in /home/gdboling/sites/pnp/manage_images.php on line 90
The path to the image I am passing as the param is:
/home/gdboling/sites/pnp/images/content/download.jpg
This image does exist. I am not getting any errors reported in any log files. Below is my system specs, phpinfo(), and code I am using. The line it is failing on is the call to imageSX because ImageCreateFromJpeg failed to load a proper image resource. Thanks for any suggestions.
System:
Xubuntu Edgy Stable
Apache2
PHP5
phpinfo()
GD Support enabled
GD Version 2.0 or higher
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.2.1
T1Lib Support enabled
GIF Read Support enabled
GIF Create Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled
function createThumb($name, $filename, $new_w, $new_h)
{
$src_image=imagecreatefromjpeg($name);
if (!$src_img)
{
echo "error loading image";
}
$old_x = imageSX($src_img);
$old_y = imageSY($src_img);
if ($old_x > $old_y)
{
$thumb_w = $new_w;
$thumb_h=$old_y*($new_h/$old_x);
}
if ($old_x < $old_y)
{
$thumb_w = $old_x*($new_w/$old_y);
$thumb_h = $new_h;
}
if ($old_x == $old_y)
{
$thumb_w = $new_w;
$thumb_h = $new_h;
}
$dst_image=ImageCreateTrueColor($thumb_w, $thumb_h);
imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $thumb_w, $thumb_y, $old_x, $old_y);
imagejpeg($dst_img, $filename);
imagedestroy($dst_img);
imagedestroy($src_img);
}