]> mj.ucw.cz Git - gallery.git/blobdiff - gal2/UCW/Gallery.pm
Gallery2: Generator
[gallery.git] / gal2 / UCW / Gallery.pm
index b2d41a6ed84851f632e996a1323a43c1ea578f11..f13889d2d032f936dde83e04ac89ca51a8a54b1f 100644 (file)
@@ -6,6 +6,8 @@ package UCW::Gallery;
 use strict;
 use warnings;
 
+use Storable;
+
 BEGIN {
        # Standard Perl module stuff
        use Exporter();
@@ -39,6 +41,8 @@ BEGIN {
        $CF{'OrigDir'} = '.';
        $CF{'PhotoDir'} = 'photo';
        $CF{'CacheDir'} = "cache",
+       $CF{'PhotoMaxWidth'} = 1024,
+       $CF{'PhotoMaxHeight'} = 1024,
 }
 
 sub LoadConfig() {
@@ -99,4 +103,20 @@ sub ReadList($) {
        return \@images;
 }
 
+sub WriteMeta($$) {
+       my ($file, $meta) = @_;
+       open META, '>', "$file.new" or die "Cannot create $file.new: $!\n";
+       Storable::nstore_fd($meta, \*META);
+       close META;
+       rename "$file.new", $file or die "Cannot rename $file.new to $file: $!\n";
+}
+
+sub ReadMeta($) {
+       my ($file) = @_;
+       open META, '<', $file or die "Cannot read $file: $!\n";
+       my $meta = Storable::fd_retrieve(\*META) or die "Cannot parse $file\n";
+       close META;
+       return $meta;
+}
+
 1;