automatically edit user-chosen images
Posted: 2015-08-31T01:34:27-07:00
Hey,
I've created an app, that lets the user select an image. Afterwards its resized and cropped with imagemagick.
Is there a way to alway have the same quality after resizing as the original image had?
Here's my code:
Thanks for the help
I've created an app, that lets the user select an image. Afterwards its resized and cropped with imagemagick.
Is there a way to alway have the same quality after resizing as the original image had?
Here's my code:
Code: Select all
$img->setImageFormat('jpg');
$img->setImageCompression(Imagick::COMPRESSION_JPEG);
$img->setImageCompressionQuality(100);
$profiles = $img->getImageProfiles("icc", true);
$img->stripImage();
if(!empty($profiles))
{
$img->profileImage("icc", $profiles['icc']);
}
list($width_orig, $height_orig) = getimagesize($origPath);
if($width_orig >= $height_orig)
{
//fix rounding problem if necessary
$xPos = (($xPos-1) + $targ_w == $_SESSION["xPos2"])?$xPos-1:$xPos;
$img->resizeImage ( 0, $targ_h, Imagick::FILTER_LANCZOS, 1);
$img->unsharpMaskImage(0 , 0.5 , 1 , 0.05);
$img->cropImage($targ_w, $targ_h, $xPos, 0);
}
Thanks for the help