hello,
I just had a quick question.
I'm trying to crop images which are 400x300 and want to crop them to become 300x300. But the thing is, my script doesn't crop but only shrinks the image so the image becomes squished. Is there any way to really crop an image or is the only way ?
here is my code:
$root = $_SERVER['DOCUMENT_ROOT'];
//echo $root;
$path = $root.'/pic/';
$image = $path.'042new.jpg';
$dimensions = getimagesize($image);
$width = $dimensions[0];
$height = $dimensions[1];
$canvas = imagecreatetruecolor(275,275);
$piece = imagecreatefromjpeg($image);
imagecopyresized($canvas, $piece, 0, 0, 0, 25, 300, 300, $width, $height);
//imagecopyresized($newcanvas, $piece, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
header('Content-type: image/jpeg');
imagejpeg($canvas);
die();