comparison mgtool.php @ 1:a07447c02b13

Use Lanczos filter for scaling instead of quadratic. Better quality and sharper results.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 13 May 2015 07:31:12 +0300
parents ac688606ec4b
children 405a02586fc2
comparison
equal deleted inserted replaced
0:ac688606ec4b 1:a07447c02b13
76 76
77 // Act based on image size vs. desired size and $thumb mode 77 // Act based on image size vs. desired size and $thumb mode
78 if ($thumb || $dim["width"] > $outDim[0] || $dim["height"] > $outDim[1]) 78 if ($thumb || $dim["width"] > $outDim[0] || $dim["height"] > $outDim[1])
79 { 79 {
80 // Image is larger 80 // Image is larger
81 $img->resizeImage($outDim[0], $outDim[1], Imagick::FILTER_QUADRATIC, 1); 81 $img->resizeImage($outDim[0], $outDim[1], Imagick::FILTER_LANCZOS, 1);
82 $img->setImageExtent($outDim[0], $outDim[1]); 82 $img->setImageExtent($outDim[0], $outDim[1]);
83 $img->normalizeImage(); 83 $img->normalizeImage();
84 $img->unsharpMaskImage(0, 0.5, 1, 0.05); 84 $img->unsharpMaskImage(0, 0.5, 1, 0.05);
85 } 85 }
86 if ($dim["width"] < $outDim[0] || $dim["height"] < $outDim[1]) 86 if ($dim["width"] < $outDim[0] || $dim["height"] < $outDim[1])
87 { 87 {
88 // Image is smaller than requested dimension(s)? 88 // Image is smaller than requested dimension(s)?
89 $img->resizeImage($outDim[0], $outDim[1], Imagick::FILTER_QUADRATIC, 1); 89 $img->resizeImage($outDim[0], $outDim[1], Imagick::FILTER_LANCZOS, 1);
90 $img->setImageExtent($outDim[0], $outDim[1]); 90 $img->setImageExtent($outDim[0], $outDim[1]);
91 $img->unsharpMaskImage(0, 0.5, 1, 0.05); 91 $img->unsharpMaskImage(0, 0.5, 1, 0.05);
92 } 92 }
93 } 93 }
94 94