photo-stats

statistics processor for the terminal
git clone https://git.clttr.info/photo-stats.git
Log (Feed) | Files | Refs (Tags) | README | LICENSE

commit b82897ccead15155d95b899705a3e4fbf6ed3d7d
parent b1aaa6f9743f70d65bc321843cc59ef458646392
Author: René Wagner <rwagner@rw-net.de>
Date:   Wed, 29 Jul 2020 10:57:58 +0200

output stats after file reading

fix missing dependency for build

Diffstat:
M.build.yml | 2++
Mphosta.pl | 30++++++++++++++----------------
2 files changed, 16 insertions(+), 16 deletions(-)

diff --git 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 @@ -27,24 +27,18 @@ my $PROGRAM = 'Photo Stats'; 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 @@ sub get_stats 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::VERSION_MESSAGE() 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'; }