]> mj.ucw.cz Git - gallery.git/blobdiff - gal2/gal-cache
Gallery2: Use FindBin to find libraries
[gallery.git] / gal2 / gal-cache
index d6ee3537987833da0b414968c739d76d156de6da..591a1cee3082e86d1778a06dbf43f63bd70ca8fb 100755 (executable)
@@ -5,7 +5,8 @@
 use strict;
 use warnings;
 
 use strict;
 use warnings;
 
-use lib '/home/mj/web/gal2';
+use FindBin;
+use lib $FindBin::Bin;
 use UCW::Gallery qw(%CF);
 
 use Image::Magick;
 use UCW::Gallery qw(%CF);
 
 use Image::Magick;
@@ -31,9 +32,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";
 
 print "Creating cache directory: $cache_dir\n";
 File::Path::mkpath($cache_dir) or die "Unable to create $cache_dir: $!\n";
 
-for my $t (@{$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;
        print "Generating $thumb_fmt thumbnails\n";
        my $thumb_meta = {};
        $meta->{thumb}->{$thumb_fmt} = $thumb_meta;