]> git.sesse.net Git - pr0n/blobdiff - perl/Sesse/pr0n/Common.pm
Yet more hacks to get the PNG file size down. This time, drop the alpha
[pr0n] / perl / Sesse / pr0n / Common.pm
index ae1d3d0ee3bc82307883bbf9e0bf69285eb9cdef..cc2b660fd3d857370b720d4884c3fba0f8b6c998 100644 (file)
@@ -576,6 +576,11 @@ sub ensure_cached {
                        my $info = Image::ExifTool::ImageInfo($fname);
                        if (make_infobox($img, $info, $r)) {
                                $img->Quantize(colors=>16, dither=>'False');
+
+                               # Since the image is grayscale, ImageMagick overrides us and writes this
+                               # as grayscale anyway, but at least we get rid of the alpha channel this
+                               # way.
+                               $img->Set(type=>'Palette');
                        } else {
                                # Not enough room for the text, make a tiny dummy transparent infobox
                                @$img = ();
@@ -586,7 +591,7 @@ sub ensure_cached {
                                $height = 1;
                        }
                                
-                       $err = $img->write(filename => $cachename, quality => 99);
+                       $err = $img->write(filename => $cachename, quality => 90, depth => 8);
                        $r->log->info("New infobox cache: $width x $height for $id.jpg");
                        
                        return ($cachename, 'image/png');