X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=gal2%2Fgal-scan;h=2cccfe13c82c6f4e2cdc373cef03eb146c497bbb;hb=9616a1f03e8290d15f0d15def6c8fb6d4e9420bf;hp=c1b70d09f843b178154a55dbef6094f436372f2a;hpb=929e3ca5d5af812fe382abe5bd88ab306a3b496a;p=gallery.git diff --git a/gal2/gal-scan b/gal2/gal-scan index c1b70d0..2cccfe1 100755 --- a/gal2/gal-scan +++ b/gal2/gal-scan @@ -5,8 +5,9 @@ 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; @@ -29,7 +30,7 @@ if (@ARGV) { 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; } } @@ -47,12 +48,17 @@ if (@ARGV) { } 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"; @@ -74,10 +80,10 @@ foreach my $f (@files) { $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";