X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=gal2%2Fgal-gen;h=3c1a6e98a81752dde349b14ae5816964b4d52310;hb=3458be45556b066cd093f5c0696c1627808d71f6;hp=970e3d2b9950aeb11e9ffe2d9fb85b6c142664f1;hpb=bfa0d113c413c2431f72405623d79cbc7b0b40f2;p=gallery.git diff --git a/gal2/gal-gen b/gal2/gal-gen index 970e3d2..3c1a6e9 100755 --- a/gal2/gal-gen +++ b/gal2/gal-gen @@ -6,9 +6,8 @@ use strict; use warnings; use lib '/home/mj/web/gal2'; -use UCW::Gallery; +use UCW::Gallery qw(%CF); -use File::Spec; use Image::Magick; use IO::Handle; use File::Spec; @@ -18,14 +17,14 @@ STDOUT->autoflush(1); 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"; + print "Using existing output directory: $photo_dir\n"; } else { - print "Creating output directory $photo_dir\n"; + print "Creating output directory: $photo_dir\n"; File::Path::mkpath($photo_dir) or die "Unable to create $photo_dir: $!\n"; } @@ -36,7 +35,7 @@ if (-f $photo_meta) { $old_meta = UCW::Gallery::ReadMeta($photo_meta); # use Data::Dumper; print "Read old meta: ", Dumper($old_meta), "\n"; } -my $meta = { 'photo' => {} }; +my $meta = { 'photo' => {}, 'sequence' => [] }; for my $f (@$orig_list) { my $id = $f->{id}; @@ -45,19 +44,19 @@ for my $f (@$orig_list) { 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; } @@ -69,7 +68,10 @@ for my $f (@$orig_list) { '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 && @@ -79,7 +81,6 @@ for my $f (@$orig_list) { $om->{h} eq $m->{h}) { # FIXME: Remove old images? print "... uptodate\n"; - $meta->{photo}->{$id} = $om; next; } @@ -121,7 +122,6 @@ for my $f (@$orig_list) { rename $tmp, $photo or die "Cannot rename $tmp to $photo: $!\n"; print "... OK\n"; - $meta->{photo}->{$id} = $m; } print "Writing meta-data\n";