dweb Posted October 31, 2013 Share Posted October 31, 2013 hi i am running this php image resize and crop script function img_process($max_width, $max_height, $source_file, $dst_dir) { $imgssize = getimagesize($source_file); $width = $imgssize[0]; $height = $imgssize[1]; $mime = $imgssize['mime']; $dst_imgs = imagecreatetruecolor($max_width, $max_height); $src_imgs = imagecreatefromjpeg($source_file); $width_new = $height * $max_width / $max_height; $height_new = $width * $max_height / $max_width; if($width_new > $width) { $h_point = (($height - $height_new) / 2); imagecopyresampled($dst_imgs, $src_imgs, 0, 0, 0, $h_point, $max_width, $max_height, $width, $height_new); } else { $w_point = (($width - $width_new) / 2); imagecopyresampled($dst_imgs, $src_imgs, 0, 0, $w_point, 0, $max_width, $max_height, $width_new, $height); } imagejpeg($dst_imgs, $dst_dir, 100); if($dst_imgs)imagedestroy($dst_imgs); if($src_imgs)imagedestroy($src_imgs); } can anyone tell me how to get it producing higher quality images? thanxs Quote Link to comment Share on other sites More sharing options...
vinny42 Posted October 31, 2013 Share Posted October 31, 2013 What's wrong with the quality you are getting? Quote Link to comment Share on other sites More sharing options...
mentalist Posted October 31, 2013 Share Posted October 31, 2013 Either make it bigger, i.e. 300dpi / 72 = 4.17, then scale w n h by 4.17, but that's probably unsatisfactory... So, use ImageMagick instead of GD http://php.net/manual/en/imagick.resampleimage.php http://php.net/manual/en/imagick.setresolution.php etc... Quote Link to comment Share on other sites More sharing options...
mentalist Posted October 31, 2013 Share Posted October 31, 2013 Just for info's sake... There may be a way using the HTML5 canvas, create it at a size then use canvas.scale(), there is a way to save this image ut can't remember it since never used it, only drawback is that it may have to be done clientside if that's acceptable? Quote Link to comment Share on other sites More sharing options...
Barand Posted October 31, 2013 Share Posted October 31, 2013 If you do it clientside you have the overhead of always downloading the original large image Quote Link to comment Share on other sites More sharing options...
mentalist Posted October 31, 2013 Share Posted October 31, 2013 If you do it clientside you have the overhead of always downloading the original large image For that after thought I was thinking of uploads...? Quote Link to comment Share on other sites More sharing options...
vinny42 Posted November 1, 2013 Share Posted November 1, 2013 If you do it clientside you have the overhead of always downloading the original large image You generaly don't resize on-demand anyway. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.