I want to resize my picture so that its not wider than 500px. The aspect ration must be the same. I don't see any changes in my image (960x960).
This is my code:
public static function resizeImage($imagename) {
list($width, $height) = getimagesize($imagename);
if($width < 500)
return $imagename;
$ratio = $width / $height;
$new_width = 500;
$new_height = $new_width / $ratio;
$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefromjpeg($imagename);
imagecopyresampled ($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
return $imagename;
}
This is the input of imagecopyresampled
Resource id #25|Resource id #27|0|0|0|0|500|500|960|960|