use strict;
use warnings;
-use lib '/home/mj/web/gal2';
-use UCW::Gallery;
+use FindBin;
+use lib $FindBin::Bin;
+use UCW::Gallery qw(%CF);
use File::Spec;
use Image::EXIF;
my @p = ();
while (my $e = readdir D) {
my $f = File::Spec->canonpath(File::Spec->catfile($in, $e));
- if ($f =~ m{\.jpe?g$}i) {
+ if ($f =~ m{\.(jpe?g|png)$}i) {
push @p, $f;
}
}
}
UCW::Gallery::LoadConfig;
+my $orig_prefix = $CF{'OrigDir'};
+$orig_prefix =~ m{/$} or $orig_prefix .= '/';
print "Scanning photos\n";
my @images = ();
foreach my $f (@files) {
- my ($fv, $fd, $ff) = File::Spec->splitpath($f);
- print "\t$ff: ";
+ my $rel_name = $f;
+ if (substr($rel_name, 0, length $orig_prefix) eq $orig_prefix) {
+ $rel_name = substr($rel_name, length $orig_prefix);
+ }
+ print "\t$rel_name: ";
my $sha = Digest::SHA->new(1);
$sha->addfile($f) or die "Cannot hash $f\n";
$o = ".";
}
push @images, {
- file => $f,
+ file => $rel_name,
id => $id,
orientation => $o,
- xfrm => $UCW::Gallery::CF{'ScanDefaultTransform'},
+ xfrm => $CF{'ScanDefaultTransform'},
title => '',
};
print "ori=$o\n";