X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=gal2%2Fgal-cache;h=5accb3fd58dace7c14bb43e7a01f71c84f4aed70;hb=3458be45556b066cd093f5c0696c1627808d71f6;hp=426335e5023f6ae98be8888246f0eaa30690e894;hpb=b89f977dc5a5d785766118992aa90a7eff7b5d3b;p=gallery.git diff --git a/gal2/gal-cache b/gal2/gal-cache index 426335e..5accb3f 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,9 +31,8 @@ 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'}}) { - my ($tw, $th) = @$t; - my $thumb_fmt = $tw . 'x' . $th; +for my $thumb_fmt (keys %{$CF{'ThumbFormats'}}) { + my ($tw, $th) = ($thumb_fmt =~ m{^(\d+)x(\d+)$}) or die "Cannot parse thumbnail format $thumb_fmt\n"; print "Generating $thumb_fmt thumbnails\n"; my $thumb_meta = {}; $meta->{thumb}->{$thumb_fmt} = $thumb_meta;