use warnings;
use lib '/home/mj/web/gal2';
-use UCW::Gallery;
+use UCW::Gallery qw(%CF);
use Image::Magick;
use IO::Handle;
UCW::Gallery::LoadConfig;
-my $orig_dir = $UCW::Gallery::CF{'OrigDir'};
+my $orig_dir = $CF{'OrigDir'};
my $orig_list = UCW::Gallery::ReadList('gallery.list') or die "Cannot read gallery.list: $!\n";
-my $photo_dir = $UCW::Gallery::CF{'PhotoDir'};
+my $photo_dir = $CF{'PhotoDir'};
if (-d $photo_dir) {
print "Using existing output directory: $photo_dir\n";
} else {
my $id = $f->{id};
my $rotate = $f->{orientation};
my $xfrm = $f->{xfrm};
- push @{$meta->{sequence}}, $id;
print "$id: ";
my $p = new Image::Magick;
- my $orig = File::Spec->rel2abs($f->{file}, $UCW::Gallery::CF{'OrigDir'});
+ my $orig = File::Spec->rel2abs($f->{file}, $CF{'OrigDir'});
my ($orig_w, $orig_h, $orig_size, $orig_format) = $p->PingImage($orig) or die "Error reading $orig\n";
print "${orig_w}x${orig_h} ";
my ($w0, $h0) = ($rotate eq "l" || $rotate eq "r") ? ($orig_h, $orig_w) : ($orig_w, $orig_h);
my ($w, $h) = ($w0, $h0);
- if ($w > $UCW::Gallery::CF{'PhotoMaxWidth'}) {
- my $s = $UCW::Gallery::CF{'PhotoMaxWidth'} / $w;
+ if ($w > $CF{'PhotoMaxWidth'}) {
+ my $s = $CF{'PhotoMaxWidth'} / $w;
$w = $w * $s;
$h = $h * $s;
}
- if ($h > $UCW::Gallery::CF{'PhotoMaxHeight'}) {
- my $s = $UCW::Gallery::CF{'PhotoMaxHeight'} / $h;
+ if ($h > $CF{'PhotoMaxHeight'}) {
+ my $s = $CF{'PhotoMaxHeight'} / $h;
$w = $w * $s;
$h = $h * $s;
}
'xf' => $xfrm,
'w' => $w,
'h' => $h,
+ 'title' => $f->{title},
};
+ $meta->{photo}->{$id} = $m;
+ push @{$meta->{sequence}}, $id;
my $om = $old_meta->{photo}->{$id};
if ($om &&
$om->{h} eq $m->{h}) {
# FIXME: Remove old images?
print "... uptodate\n";
- $meta->{photo}->{$id} = $om;
next;
}
rename $tmp, $photo or die "Cannot rename $tmp to $photo: $!\n";
print "... OK\n";
- $meta->{photo}->{$id} = $m;
}
print "Writing meta-data\n";