X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=gal2%2FUCW%2FGallery.pm;h=f13889d2d032f936dde83e04ac89ca51a8a54b1f;hb=bfa0d113c413c2431f72405623d79cbc7b0b40f2;hp=b2d41a6ed84851f632e996a1323a43c1ea578f11;hpb=168379589bee5b5d1c46f749748c3d3b1fd80c9a;p=gallery.git diff --git a/gal2/UCW/Gallery.pm b/gal2/UCW/Gallery.pm index b2d41a6..f13889d 100644 --- a/gal2/UCW/Gallery.pm +++ b/gal2/UCW/Gallery.pm @@ -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;