so im pulling an error:
Warning: imagegif() [function.imagegif]: Unable to open 'megaphone.gif' for writing in /var/www/htdocs/~scripts/image_resize/index.php on line 42
after that i get an output of "1"
CODE:
<?php
function resizeIMG($filename, $width) {
// Get new dimensions
list($width_orig, $height_orig) = getimagesize($filename);
$height = (int) (($width / $width_orig) * $height_orig);
// Resample
$image_p = imagecreatetruecolor($width, $height);
$format = strtolower(substr(strrchr($filename,"."),1));
switch($format)
{
case 'gif' :
$type ="gif";
$image = imagecreatefromgif($filename);
break;
case 'png' :
$type ="png";
$image = imagecreatefrompng($filename);
break;
case 'jpg' :
$type ="jpg";
$image = imagecreatefromjpeg($filename);
break;
case 'jpeg' :
$type ="jpg";
$image = imagecreatefromjpeg($filename);
break;
default :
die ("ERROR; UNSUPPORTED IMAGE TYPE");
break;
}
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
// Output
if($type=="gif")
{
imagegif($image_p, $filename);
}
elseif($type=="jpg")
{
imagejpeg($image_p, $filename);
}
elseif($type=="png")
{
imagepng($image_p, $filename);
}
elseif($type=="bmp")
{
imagewbmp($image_p, $filename);
}
return true;
}
echo resizeIMG('megaphone.gif',100);
?>
but i dont understand b/c i do not want to actually write any image files... it should all be on the fly