X-Git-Url: https://git.sesse.net/?p=pr0n;a=blobdiff_plain;f=perl%2FSesse%2Fpr0n%2FCommon.pm;h=000b3511464291baa52f76c35195bdd6b58da21b;hp=d863b2180340736c1c9c0edee9c7501f183ae920;hb=0f41d1a8beed02aacf3e08cc963ccc0a765427f7;hpb=3beccc23567ed94b627434de774fe50a34b53cba diff --git a/perl/Sesse/pr0n/Common.pm b/perl/Sesse/pr0n/Common.pm index d863b21..000b351 100644 --- a/perl/Sesse/pr0n/Common.pm +++ b/perl/Sesse/pr0n/Common.pm @@ -35,7 +35,7 @@ BEGIN { require Sesse::pr0n::Config_local; }; - $VERSION = "v2.52"; + $VERSION = "v2.53"; @ISA = qw(Exporter); @EXPORT = qw(&error &dberror); %EXPORT_TAGS = qw(); @@ -371,7 +371,7 @@ sub ensure_cached { my ($r, $filename, $id, $dbwidth, $dbheight, $infobox, $xres, $yres, @otherres) = @_; my $fname = get_disk_location($r, $id); - unless (defined($xres) && ($xres < $dbheight || $yres < $dbwidth || !defined($dbwidth) || !defined($dbheight) || $xres == -1)) { + unless (defined($xres) && (!defined($dbwidth) || !defined($dbheight) || $xres < $dbheight || $yres < $dbwidth || $xres == -1)) { return ($fname, 0); } @@ -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); @@ -557,10 +557,16 @@ sub make_infobox { # Apache2::ServerUtil->server->log_error(join(':', keys %$info)); + my $iso = undef; if (defined($info->{'NikonD1-ISOSetting'})) { - push @classic_fields, [ $info->{'NikonD1-ISOSetting'}->[1] . " ISO", 0 ]; + $iso = $info->{'NikonD1-ISOSetting'}; + } elsif (defined($info->{'ISO'})) { + $iso = $info->{'ISO'}; } elsif (defined($info->{'ISOSetting'})) { - push @classic_fields, [ $info->{'ISOSetting'} . " ISO" ]; + $iso = $info->{'ISOSetting'}; + } + if (defined($iso) && $iso =~ /(\d+)/) { + push @classic_fields, [ $1 . " ISO", 0 ]; } if (defined($info->{'ExposureBiasValue'}) && $info->{'ExposureBiasValue'} ne "0") {