Jump to content

high res image resizer


dweb

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/283478-high-res-image-resizer/
Share on other sites

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.