{
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)
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=?',
$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: $!";
"date" timestamp without time zone,
takenby character varying NOT NULL,
selected boolean DEFAULT false,
+ model character varying,
+ lens character varying,
FOREIGN KEY (vhost,event) REFERENCES events (vhost,event)
);
vhost character varying NOT NULL
);
+-- Mainly used for manual queries -- usually too slow to be very useful
+-- for web views in the long run.
CREATE TABLE exif_info (
image integer NOT NULL REFERENCES images (id) ON DELETE CASCADE,
key varchar NOT NULL,
ALTER TABLE deleted_images ALTER COLUMN height SET DEFAULT NULL;
UPDATE deleted_images SET width=NULL,height=NULL WHERE width=-1 OR height=-1;
ALTER TABLE deleted_images ADD CONSTRAINT width_height_nullity CHECK ((width IS NULL) = (height IS NULL));
+
+-- model/lens denormalization (reduce usage of exif_info)
+ALTER TABLE images ADD COLUMN model varchar;
+ALTER TABLE images ADD COLUMN lens varchar;
+UPDATE images SET lens=COALESCE(
+ TRIM((
+ SELECT value FROM exif_info WHERE key='Lens' AND images.id=exif_info.image
+ )),
+ TRIM((
+ SELECT value FROM exif_info WHERE key='LensSpec' AND images.id=exif_info.image
+ ))
+), model=TRIM((
+ SELECT value FROM exif_info WHERE key='Model' AND images.id=exif_info.image
+));
+