So I am trying to write a little script to crop a users image. I would send some information (width, height, alignment properties and image url) to the script and it should return the image cropped. However, it’s not working… Just an “image not found” symbol :/ Here is my script, any thoughts?
<?php
session_start();
header('Content-type: image/jpeg');
$w=$_GET['w'];
$h=$_GET['h'];
$x=$_GET['x'];
$y=$_GET['y'];
$filename="http://www.domain.com/".$_GET['src'];
$file_ext = substr($filename, strrpos($filename, ".") + 1);
$ext='';
if($file_ext=='jpg')
{
$image = imagecreatefromjpeg($filename);
}
else if ($file_ext=='gif')
{
$image = imagecreatefromgif($filename);
}
else if ($file_ext=='png')
{
$image = imagecreatefrompng($filename);
}
$crop = imagecreatetruecolor($w,$h);
imagecopy($crop, $image, 0, 0, $x, $y, $w, $h);
imagejpeg($crop);
?>
Edit: Looks like this is the error: Fatal error: Call to undefined function imagecreatetruecolor() in domainpath/crop.php on line 24 Is there anything I need to do to load this function?
Using ImageMagick, try this;