X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=perl%2FSesse%2Fpr0n%2FCommon.pm;h=eff6fc13ecb991196a64fb8ea695708f1cf6d66b;hb=9d97b1243a78e8703fefb2a1da2794a6434912c4;hp=dcaf244af5e84330988d93c12b858de539f68d91;hpb=4c7426477a73edd5ad88bfebda56575019d5ca06;p=pr0n diff --git a/perl/Sesse/pr0n/Common.pm b/perl/Sesse/pr0n/Common.pm index dcaf244..eff6fc1 100644 --- a/perl/Sesse/pr0n/Common.pm +++ b/perl/Sesse/pr0n/Common.pm @@ -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,6 +258,22 @@ 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=?', @@ -271,6 +283,7 @@ sub update_image_info { $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: $!";