X-Git-Url: https://git.sesse.net/?p=pr0n;a=blobdiff_plain;f=perl%2FSesse%2Fpr0n%2FCommon.pm;h=cc2b660fd3d857370b720d4884c3fba0f8b6c998;hp=027268a2c469faeeb2b5d232d91e619753a8b341;hb=a48970df0c4bf4d7d106bfa77149c5774e696ff4;hpb=133c9fb7f197da55e8b85e98a17ae6a184a28832 diff --git a/perl/Sesse/pr0n/Common.pm b/perl/Sesse/pr0n/Common.pm index 027268a..cc2b660 100644 --- a/perl/Sesse/pr0n/Common.pm +++ b/perl/Sesse/pr0n/Common.pm @@ -574,7 +574,14 @@ sub ensure_cached { $img->Read('xc:white'); my $info = Image::ExifTool::ImageInfo($fname); - if (!make_infobox($img, $info, $r)) { + 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 = (); $img->Set(size=>"1x1"); @@ -584,7 +591,7 @@ sub ensure_cached { $height = 1; } - $err = $img->write(filename => $cachename); + $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');