X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=perl%2FSesse%2Fpr0n%2FCommon.pm;h=eff6fc13ecb991196a64fb8ea695708f1cf6d66b;hb=9d97b1243a78e8703fefb2a1da2794a6434912c4;hp=43ea98853ffbd6e41f9e108512009d46063f1cb5;hpb=c98436420fa7749e3af1f3698ccf9958dffbd4db;p=pr0n diff --git a/perl/Sesse/pr0n/Common.pm b/perl/Sesse/pr0n/Common.pm index 43ea988..eff6fc1 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.41"; + $VERSION = "v2.49"; @ISA = qw(Exporter); @EXPORT = qw(&error &dberror); %EXPORT_TAGS = qw(); @@ -244,10 +244,6 @@ sub update_image_info { { local $dbh->{AutoCommit} = 0; - $dbh->do('UPDATE images SET width=?, height=?, date=? WHERE id=?', - undef, $width, $height, $datetime, $id) - or die "Couldn't update width/height in SQL: $!"; - # EXIF information $dbh->do('DELETE FROM exif_info WHERE image=?', undef, $id) @@ -262,15 +258,32 @@ sub update_image_info { or die "Couldn't insert EXIF information in database: $!"; } + # Model/Lens + my $model = $exiftool->GetValue('Model', 'ValueConv'); + my $lens = $exiftool->GetValue('Lens', 'ValueConv'); + $lens = $exiftool->GetValue('LensSpec', 'ValueConv') if (!defined($lens)); + + $model =~ s/^\s*//; + $model =~ s/\s*$//; + + $lens =~ s/^\s*//; + $lens =~ s/\s*$//; + + # Now update the main table with the information we've got + $dbh->do('UPDATE images SET width=?, height=?, date=?, model=?, lens=? WHERE id=?', + undef, $width, $height, $datetime, $model, $lens, $id) + or die "Couldn't update width/height in SQL: $!"; + # Tags my @tags = $exiftool->GetValue('Keywords', 'ValueConv'); $dbh->do('DELETE FROM tags WHERE image=?', undef, $id) or die "Couldn't delete old tag information in SQL: $!"; - my $q = $dbh->prepare('INSERT INTO tags (image,tag) VALUES (?,?)') + $q = $dbh->prepare('INSERT INTO tags (image,tag) VALUES (?,?)') or die "Couldn't prepare inserting tag information: $!"; + for my $tag (@tags) { $q->execute($id, guess_charset($tag)) or die "Couldn't insert tag information in database: $!"; @@ -356,7 +369,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 || $dbwidth == -1 || $dbheight == -1 || $xres == -1)) { + unless (defined($xres) && ($xres < $dbheight || $yres < $dbwidth || !defined($dbwidth) || !defined($dbheight) || $xres == -1)) { return ($fname, 0); } @@ -405,7 +418,7 @@ sub ensure_cached { my $height = $img->Get('rows'); # Update the SQL database if it doesn't contain the required info - if ($dbwidth == -1 || $dbheight == -1) { + if (!defined($dbwidth) || !defined($dbheight)) { $r->log->info("Updating width/height for $id: $width x $height"); update_image_info($r, $id, $width, $height); } @@ -551,7 +564,7 @@ sub make_infobox { push @classic_fields, $info->{'ISOSetting'} . " ISO"; } - if (defined($info->{'ExposureBiasValue'}) && $info->{'ExposureBiasValue'} != 0) { + if (defined($info->{'ExposureBiasValue'}) && $info->{'ExposureBiasValue'} ne "0") { push @classic_fields, $info->{'ExposureBiasValue'} . " EV"; } elsif (defined($info->{'ExposureCompensation'}) && $info->{'ExposureCompensation'} != 0) { push @classic_fields, $info->{'ExposureCompensation'} . " EV";