I'm simply trying to crop a JPEG image (no scaling) using PHP. Here is my function, along with the inputs.
function cropPicture($imageLoc, $width, $height, $x1, $y1) {
$newImage = imagecreatetruecolor($width, $height);
$source = imagecreatefromjpeg($imageLoc);
imagecopyresampled($newImage,$source,0,0,$x1,$y1,$width,$height,$width,$height);
imagejpeg($newImage,$imageLoc,90);
}
When I call it as follows--cropPicture('image.jpg', 300, 300, 0, 0)
--the function completes properly, but I'm left with a black image that is 300x300 px (in other words, a blank canvas). Am I passing in the wrong arguments?
The image exists and is writeable.