I am trying to create thumbnails in ratio to a pre-defined width.
However, My images are distorted out of ratio, here is what i have, can someone give me the correct way to get the ratio for the height?
Thanks in advance!
$src_img = imagecreatefromJPEG($path . $current["id"] . "_" . $current["title"] . "/" . $image[$a]) or die("Failed to create image");
$compression = $settings["compression"];
if ($settings["scaleby"]=="width") {
$ratio = (imagesx($src_img)/imagesy($src_img));
$new_width = $settings["scalevalue"];
$new_height = $new_width/$ratio;
}
$new_width = 100;
$dst_img = imagecreatetruecolor($new_width,$new_height);
imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $new_width, $new_height, imagesx($src_img), imagesy($src_img));
imagejpeg($dst_img, $path . $current["id"] . "_" . $current["title"] . "/temp/" . $image[$a], $compression) or die("Died on call to imagejpeg() function");