Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
cinder
Posts: 1 Joined: 2015-08-31T01:23:00-07:00
Authentication code: 1151
Contact:
Post
by cinder » 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:
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
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Contact:
Post
by fmw42 » 2015-08-31T09:42:26-07:00
I believe if you leave off the
$img->setImageCompressionQuality(100);
Imagemagick will try to detect the quality setting in the input and use it. If it fails to detect it, then it assigns the default 92. see
http://www.imagemagick.org/script/comma ... hp#quality
You could also detect the input quality your self from the verbose information and reassign it in your processing
Users browsing this forum: Ahrefs [Bot] , Amazon [Bot] , Bing [Bot] , Semrush [Bot] and 2 guests