use UCW::Gallery;
use File::Spec;
+use Image::Magick;
my $photos_root = $ENV{HOME} . '/photos';
open I, "$album/index.cgi" or die "Cannot find $album/index.cgi\n";
open W, ">$album/gallery.new" or die "Cannot create $album/gallery.new\n";
+open T, ">$album/gallery.thumb" or die "Cannot create $album/gallery.thumb\n";
my %opt = ();
my %found_dirs = ();
my @items = ();
if (/^\s+"(\w+)" => "(.*)",?$/) {
$opt{$1} = $2;
print "Option: $1 = $2\n";
- } elsif (/^img\("([^"]+)\.jpe?g", "([^"]*)"\);\s*# (\S+)/) {
+ } elsif (/^img\("([^"]+)(\.jpe?g)", "([^"]*)"\);\s*# (\S+)/) {
my $nr = $1;
- my $title = $2;
- my $file = $3;
+ my $ext = $2;
+ my $title = $3;
+ my $file = $4;
$file =~ s{^.*/}{}g;
my $map = $map{$file};
($src ? $src->{xform} : '.'),
($title ne "" ? $title : '-'),
), "\n";
+
+
+ my $thumb = "../static/photos/$album/$nr-thumb.jpg";
+ if (!-f $thumb) {
+ print STDERR "$album: Cannot find thumbnail for photo $nr ($thumb)\n";
+ print T "1 1\n";
+ } else {
+ my $im = new Image::Magick;
+ my ($thumb_w, $thumb_h, $thumb_size, $thumb_format) = $im->PingImage($thumb) or die "Error reading $thumb\n";
+ print T "$thumb $thumb_w $thumb_h\n";
+ }
} elsif (/^($|#|require|SetOptions|\)|Start|Finish)/) {
# Nothing important
} else {
print STDERR "$album/index.cgi: Parse error at line $.: $_\n";
}
}
+close T;
close W;
close I;