diff --git a/.build.yml b/.build.yml

index 2ffc9ebbae4039503fb2f6bbee14fad983a47125..e31635d1f0a25e6b6989b3a2a710ef800a68b249 100644

--- a/.build.yml

+++ b/.build.yml

@@ -3,6 +3,8 @@ packages:

- perl

- perl-par-packer

- perl-file-homedir

+ - perl-dbi

+ - perl-dbd-sqlite

sources:

- https://git.sr.ht/~rwa/photo-stats

artifacts:

diff --git a/phosta.pl b/phosta.pl

index c2194985f5b91f323eae97d75dea0864a0eddd36..41d681905670593bf1a613ee3d71fe37a7db03a6 100755

--- a/phosta.pl

+++ b/phosta.pl

@@ -27,24 +27,18 @@

my $configfile = catfile(File::HomeDir->my_home, '.photo-stats.conf');

# read commandline switches

-my $opt_s=0;

+our $opt_p='';

getconfig($configfile);

-#getopts('slr:f:c:') or die "Invalid parameters provided! See 'art_file_mover.pl --help' for more details.";

+getopts('p:') or die "Invalid parameters provided! See 'phosta.pl --help' for more details.";

+say $opt_p;

+#if ( $opt_s ) { writeconfig($configfile); }

-# read remaining commandline args for source dir

-# last dir will win

-my $destination_dir = getcwd;

-foreach my $arg ( @ARGV )

-{

- $destination_dir = $arg;

+if ( $opt_p ne '' ) {

+ get_stats($opt_p);

}

-if ( $opt_s ) { writeconfig($configfile); }

-

-get_stats($destination_dir);

-

exit 0;

sub get_stats

@@ -60,19 +54,22 @@ my $dbh = DBI->connect($dsn, $userid, $password, { RaiseError => 1 })

or die $DBI::errstr;

$dbh->do('DELETE FROM photos');

my $errorcount = 0;

+ my $emptycount = 0;

foreach (@lines)

{

chomp $_;

my ( $file, $maker, $model, $lens, $lensmodel, $fl, $fl35, $apert, $ss, $iso, $flash, $date ) = split(/#/, $_);

$lens = ($lens ne '-') ? $lens : $lensmodel;

- ($date ne '-' && $model ne '-') or next;

+ if ($date eq '-' || $model eq '-') { $emptycount++; next; }

my $stmt = "INSERT INTO photos (file, maker, model, lens, focallength, focallength35mm, aperture, shutterspeed, iso, flash, datetimeoriginal)

VALUES ('$file', '$maker', '$model', '$lens', '$fl', '$fl35', '$apert', '$ss', '$iso', '$flash', '$date')";

- my $rv = $dbh->do($stmt) or die $DBI::errstr;

+ my $rv = $dbh->do($stmt) or $errorcount++;

}

$dbh->disconnect();

+ say sprintf('%5d', $emptycount). ' image files skipped due to missing EXIF data';

+ say sprintf('%5d', $errorcount). ' image files skipped due to errors';

}

sub getconfig

@@ -100,11 +97,12 @@

sub main::HELP_MESSAGE

{

say '';

- say 'Find all by ART converted files in the current folder and their corresponding RAWs and move them to specified directory.';

+ say 'Extract the EXIF data of images (currently jpg only) and feed them to a database.';

say '';

- say 'usage: phosta(.pl) [options] <source folder>';

+ say 'usage: phosta(.pl) [options]';

say '';

say 'options:';

+ say ' -p <source folder> : populate database from the files in the specified folder';

say ' -s : safe current options (-r, -f, -c only) to user profile. If present the saved values are applied automatically.';

say ' --help : show this help';

}