$filename = '/home/hey/Desktop/images/oldImage.jpg';
$percent = 0.5;
// Get new dimensions
list($width, $height) = getimagesize($filename);
$new_width = $width * $percent;
$new_height = $height * $percent;
// Resample
$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
file_put_contents("/home/hey/Desktop/images/oldImage.jpg", imagejpeg($image_p));
I just want to crop oldImage a little bit and save it again. What's wrong? Thanks.
edit: Image is just not created. It creates empty image.