blasterstudios
Technical User
I would like to create thumbnails from photos as they are uploaded. It seems to be working, however, the thumbnail quality is very poor and it's not the right aspect ratio.
This is the function I'm using to create the thumbs.
What in here do I need to change to fix the quality and aspect ratio problem?
This is the function I'm using to create the thumbs.
Code:
function thumbnail($image_path,$thumb_path,$image_name,$thumb_width)
{
$src_img = imagecreatefromjpeg("$image_path/$image_name");
$origw=imagesx($src_img);
$origh=imagesy($src_img);
$new_w = $thumb_width;
$diff=$origw/$new_w;
$new_h=$new_w;
$dst_img = imagecreate($new_w,$new_h);
imagecopyresized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,imagesx($src_img),imagesy($src_img));
imagejpeg($dst_img, "$thumb_path/$image_name");
return true;
}
What in here do I need to change to fix the quality and aspect ratio problem?