From: Martin Mares Date: Sun, 23 Dec 2012 22:51:00 +0000 (+0100) Subject: Gallery2: Import %CF X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=11e566792f70153b513d4916f0540addcb0147ae;p=gallery.git Gallery2: Import %CF --- diff --git a/gal2/gal-cache b/gal2/gal-cache index 426335e..d6ee353 100755 --- a/gal2/gal-cache +++ b/gal2/gal-cache @@ -6,7 +6,7 @@ use strict; use warnings; use lib '/home/mj/web/gal2'; -use UCW::Gallery; +use UCW::Gallery qw(%CF); use Image::Magick; use IO::Handle; @@ -17,13 +17,13 @@ STDOUT->autoflush(1); UCW::Gallery::LoadConfig; -my $photo_dir = $UCW::Gallery::CF{'PhotoDir'}; +my $photo_dir = $CF{'PhotoDir'}; my $photo_meta = File::Spec->catfile($photo_dir, 'gallery.meta'); print "Reading meta-data from $photo_meta\n"; -f $photo_meta or die "Cannot load $photo_meta\n"; my $meta = UCW::Gallery::ReadMeta($photo_meta); -my $cache_dir = $UCW::Gallery::CF{'CacheDir'}; +my $cache_dir = $CF{'CacheDir'}; if (-d $cache_dir) { print "Deleting old cache directory: $cache_dir\n"; File::Path::remove_tree($cache_dir); @@ -31,7 +31,7 @@ if (-d $cache_dir) { print "Creating cache directory: $cache_dir\n"; File::Path::mkpath($cache_dir) or die "Unable to create $cache_dir: $!\n"; -for my $t (@{$UCW::Gallery::CF{'ThumbSizes'}}) { +for my $t (@{$CF{'ThumbSizes'}}) { my ($tw, $th) = @$t; my $thumb_fmt = $tw . 'x' . $th; print "Generating $thumb_fmt thumbnails\n"; diff --git a/gal2/gal-gen b/gal2/gal-gen index d8edb57..7d244fe 100755 --- a/gal2/gal-gen +++ b/gal2/gal-gen @@ -6,7 +6,7 @@ use strict; use warnings; use lib '/home/mj/web/gal2'; -use UCW::Gallery; +use UCW::Gallery qw(%CF); use Image::Magick; use IO::Handle; @@ -17,10 +17,10 @@ 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"; } else { @@ -45,19 +45,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; } diff --git a/gal2/gal-scan b/gal2/gal-scan index 39dd6b0..aa286af 100755 --- a/gal2/gal-scan +++ b/gal2/gal-scan @@ -6,7 +6,7 @@ use strict; use warnings; use lib '/home/mj/web/gal2'; -use UCW::Gallery; +use UCW::Gallery qw(%CF); use File::Spec; use Image::EXIF; @@ -47,7 +47,7 @@ if (@ARGV) { } UCW::Gallery::LoadConfig; -my $orig_prefix = $UCW::Gallery::CF{'OrigDir'}; +my $orig_prefix = $CF{'OrigDir'}; $orig_prefix =~ m{/$} or $orig_prefix .= '/'; print "Scanning photos\n"; @@ -82,7 +82,7 @@ foreach my $f (@files) { file => $rel_name, id => $id, orientation => $o, - xfrm => $UCW::Gallery::CF{'ScanDefaultTransform'}, + xfrm => $CF{'ScanDefaultTransform'}, title => '', }; print "ori=$o\n";