I'm just trying to crop a JPEG image (without scaling) using PHP. Here is my function as well as the input.
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 is executed correctly, but I still have a black image of 300x300 px in size (in other words, an empty canvas). Am I passing the wrong arguments?
The image exists and is being recorded.
source
share