From 8d985e97799233f11b1e596a22b09a91b1160967 Mon Sep 17 00:00:00 2001 From: Joe McGill Date: Wed, 3 Feb 2016 23:06:33 -0600 Subject: [PATCH] Advanced image compression: remove posterization This removes the posterization filter from the advanced image compression settings to substantially reduce the CPU load which could cause image resizing to fail (see #150). After digging into the research @nwtn did to come up with these settings, it turns out that posterization only improves file sizes for PNGs and can actually lead to slightly larger file sizes for JPG images. --- class-respimg.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/class-respimg.php b/class-respimg.php index 2050a46..11fe9b2 100644 --- a/class-respimg.php +++ b/class-respimg.php @@ -29,9 +29,9 @@ class Respimg extends Imagick { * * This function is basically equivalent to: * - * $optim == true: `mogrify -path OUTPUT_PATH -filter Triangle -define filter:support=2.0 -thumbnail OUTPUT_WIDTH -unsharp 0.25x0.08+8.3+0.045 -dither None -posterize 136 -quality 82 -define jpeg:fancy-upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude-chunk=all -interlace none -colorspace sRGB INPUT_PATH` + * $optim == true: `mogrify -path OUTPUT_PATH -filter Triangle -define filter:support=2.0 -thumbnail OUTPUT_WIDTH -unsharp 0.25x0.08+8.3+0.045 -quality 82 -define jpeg:fancy-upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude-chunk=all -interlace none -colorspace sRGB INPUT_PATH` * - * $optim == false: `mogrify -path OUTPUT_PATH -filter Triangle -define filter:support=2.0 -thumbnail OUTPUT_WIDTH -unsharp 0.25x0.25+8+0.065 -dither None -posterize 136 -quality 82 -define jpeg:fancy-upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude-chunk=all -interlace none -colorspace sRGB -strip INPUT_PATH` + * $optim == false: `mogrify -path OUTPUT_PATH -filter Triangle -define filter:support=2.0 -thumbnail OUTPUT_WIDTH -unsharp 0.25x0.25+8+0.065 -quality 82 -define jpeg:fancy-upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude-chunk=all -interlace none -colorspace sRGB -strip INPUT_PATH` * * @access public * @@ -50,7 +50,7 @@ public function smartResize( $columns, $rows, $optim = false ) { } else { $this->unsharpMaskImage( 0.25, 0.25, 8, 0.065 ); } - $this->posterizeImage( 136, false ); + $this->setImageCompressionQuality( 82 ); $this->setOption( 'jpeg:fancy-upsampling', 'off' ); $this->setOption( 'png:compression-filter', '5' );