]> mj.ucw.cz Git - gallery.git/blobdiff - gal2/gal-scan
Gallery2: Missing bits
[gallery.git] / gal2 / gal-scan
index c1b70d09f843b178154a55dbef6094f436372f2a..aa286aff234d6b5a5729213014e5f92f3a441708 100755 (executable)
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 
 use lib '/home/mj/web/gal2';
-use UCW::Gallery;
+use UCW::Gallery qw(%CF);
 
 use File::Spec;
 use Image::EXIF;
@@ -29,7 +29,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 +47,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 +79,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";