From: Steinar H. Gunderson Date: Fri, 25 Jan 2008 18:47:23 +0000 (+0100) Subject: Keep JPEGs in the YCbCr colorspace instead of going between YCbCr and RGB X-Git-Url: https://git.sesse.net/?p=pr0n;a=commitdiff_plain;h=0f41d1a8beed02aacf3e08cc963ccc0a765427f7 Keep JPEGs in the YCbCr colorspace instead of going between YCbCr and RGB just to scale it. Seems to improve overall performance about 10% for 400x600 (800x600 portrait :-) ) images, from 1.1 to 1.0 seconds. --- diff --git a/perl/Sesse/pr0n/Common.pm b/perl/Sesse/pr0n/Common.pm index e339fd3..000b351 100644 --- a/perl/Sesse/pr0n/Common.pm +++ b/perl/Sesse/pr0n/Common.pm @@ -401,6 +401,11 @@ sub ensure_cached { $err = $magick->Read(file => \*DCRAW); close(DCRAW); } else { + # We always want YCbCr JPEGs. Setting this explicitly here instead of using + # RGB is slightly faster (no colorspace conversion needed) and works equally + # well for our uses. (Ideally we'd be able to keep the image subsampled and + # planar, but that would probably be difficult for ImageMagick to expose.) + $magick->Set(colorspace=>'YCbCr'); $err = $magick->Read($fname); } @@ -425,11 +430,6 @@ sub ensure_cached { update_image_info($r, $id, $width, $height); } - # We always want RGB JPEGs - if ($img->Get('Colorspace') eq "CMYK") { - $img->Set(colorspace=>'RGB'); - } - while (defined($xres) && defined($yres)) { my ($nxres, $nyres) = (shift @otherres, shift @otherres); my $cachename = get_cache_location($r, $id, $xres, $yres, $infobox);