php imagecreate adjust width image creation based on height px

319 views Asked by At

Hey guys I have a small issue, i have an file upload that resizes the image into thumbnail by max width of 120px and ratios the height based on that.

Here is my code

$width = 100; //*** Set a Fix Width & Height (Auto caculate) ***//
$size = GetimageSize($images);
$height = round($width * $size[1] / $size[0]);
$images_orig = imagecreatefromjpeg($images);
$photoX = ImagesX($images_orig);
$photoY = ImagesY($images_orig);
$images_fin = ImageCreateTrueColor($width, $height);
ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width + 1, $height + 1, $photoX, $photoY);
ImageJPEG($images_fin, $new_images);

What I am wanting to do instead os upload the image with a max height of 120px and ratio the width proportionally.

What variables do I have to reverse?

0

There are 0 answers