Hey does any one know how to resize an image using php. I had a code before but it doesn't work in php 4
My code before
$image = $_GET['image'] ;
$newwidth = $_GET['newwidth'];
$newheight = $_GET['newheight'];
$height = $_GET['height'];
$width = $_GET['width'];
if (ereg('png$',$_GET[image])) { $src = imagecreatefrompng($image); }
if (ereg('jpg$',$_GET[image])) { $src = imagecreatefromjpeg($image); }
if (ereg('JPG$',$_GET[image])) { $src = imagecreatefromjpeg($image); }
if (ereg('gif$',$_GET[image])) { $src = imagecreatefromgif($image); }
$im = imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($im,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
imagejpeg($im, '',85);
imagedestroy($im);
?>
Thanks
Automatic Image Resize
Moderator: General Moderators
I just added the correct header for the filetype, and it worked.
Code: Select all
header("Content-type: image/jpeg"); // Change to fit png and gif also...You can use Mogrify or other applications, but that depends on if they are installed, just as the above code needs GD to be installed to work.
Do a;
...and see if you can see what version (if any) of GD is installed. Perhaps that might help some more.
Do a;
Code: Select all
<?php phpinfo(); ?>image magick
is there a way using image magick?