photo-stats

Unnamed repository; edit this file 'description' to name the repository.
git clone git://code.clttr.info/photo-stats.git
Log | Files | Refs | README | LICENSE

commit c29e2d13cbbcaba588d607d926c6240b82e03ac7
parent d40c0f148c492361dc8dc8371e1f9d3df678e04a
Author: René Wagner <rwagner@rw-net.de>
Date:   Sat, 15 Aug 2020 14:37:57 +0200

add field "lensmake" to import

improve data cleanup on import

Diffstat:
Mphosta.pl | 25+++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/phosta.pl b/phosta.pl @@ -19,7 +19,7 @@ use File::HomeDir; $Getopt::Std::STANDARD_HELP_VERSION = 'true'; -my $VERSION = '0.5'; +my $VERSION = '0.6'; my $PROGRAM = 'Photo Stats'; my $configfile = catfile(File::HomeDir->my_home, '.phosta.conf'); @@ -57,7 +57,7 @@ sub validate my @group_params = ('year', 'month', 'week', 'hour', ''); if ( ! ($opt_g ~~ @group_params) ) { return 0; } - my @select_params = ('maker', 'model', 'lens', 'aperture', 'exposuretime', 'iso', 'focallength', 'focallength35mm', ''); + my @select_params = ('maker', 'model', 'lensmake', 'lens', 'aperture', 'exposuretime', 'iso', 'focallength', 'focallength35mm', ''); foreach (split (/,/, $opt_s)) { if ( ! ($_ ~~ @select_params) ) { return 0; } @@ -87,7 +87,7 @@ sub create_db my ($dbfile) = @_; my $dbh = DBI->connect($dsn, '', '', { RaiseError => 1 }) or die $DBI::errstr; - my $stmt = 'CREATE TABLE photos (file TEXT PRIMARY KEY, maker TEXT, model TEXT, lens TEXT, focallength INTEGER, focallength35mm INTEGER, aperture DECIMAL, exposuretime TEXT, iso INTEGER, flash TEXT, datetimeoriginal DATETIME);'; + my $stmt = 'CREATE TABLE photos (file TEXT PRIMARY KEY, maker TEXT, model TEXT, lensmake TEXT, lens TEXT, focallength INTEGER, focallength35mm INTEGER, aperture DECIMAL, exposuretime TEXT, iso INTEGER, flash TEXT, datetimeoriginal DATETIME);'; my $rv = $dbh->do($stmt); } @@ -97,7 +97,7 @@ sub populate_db say "Scanning $destination_dir for images..."; - my $cmd = "exiftool -fast2 -r -m -f -p '\$filepath##\$make##\$model##\$lens##\$lensmodel##\$focallength##\$focallengthin35mmformat##\$aperture##\$exposuretime##\$iso##\$flash##\$datetimeoriginal' -d \"%Y-%m-%d %H:%M:%S\" -ext jpg " . $destination_dir; + my $cmd = "exiftool -fast2 -r -m -f -p '\$filepath##\$make##\$model##\$lensmake##\$lens##\$lensmodel##\$focallength##\$focallengthin35mmformat##\$aperture##\$exposuretime##\$shutterspeed##\$iso##\$flash##\$datetimeoriginal' -d \"%Y-%m-%d %H:%M:%S\" -ext jpg " . $destination_dir; my @lines = qx($cmd); my $dbh = DBI->connect($dsn, '', '', { RaiseError => 1 }) or die $DBI::errstr; @@ -106,16 +106,21 @@ sub populate_db foreach (@lines) { chomp $_; - my ($file, $maker, $model, $lens, $lensmodel, $fl, $fl35, $apert, $exposuretime, $iso, $flash, $datetimeoriginal) = split(/#/, $_); + my ($file, $maker, $model, $lensmake, $lens, $lensmodel, $fl, $fl35, $apert, $exposuretime, $ss, $iso, $flash, $datetimeoriginal) = split(/#/, $_); - if ($model eq '-') { $emptycount++; next; } - $lens = ($lens ne '-') ? $lens : $lensmodel; + my @forbidden_content = ('Unknown', 'N/A', '-', ''); + #if ($model eq '-') { $emptycount++; next; } + + if ( $maker ~~ @forbidden_content) { $maker = '-'; } + if ( $model ~~ @forbidden_content) { $model = '-'; } + $lens = ($lens ~~ @forbidden_content) ? $lensmodel : $lens; + if ( $lens ~~ @forbidden_content) { $lens = '-'; } $apert = ($apert ne '-') ? sprintf("%.1f", $apert) : $apert; $exposuretime = (looks_like_number($exposuretime) && $exposuretime < 1) ? "1/". POSIX::lround(1/$exposuretime) : $exposuretime; if ($datetimeoriginal eq '0000:00:00 00:00:00') { $datetimeoriginal = '-'; } - my $stmt = "INSERT OR REPLACE INTO photos (file, maker, model, lens, focallength, focallength35mm, aperture, exposuretime, iso, flash, datetimeoriginal) - VALUES ('$file', '$maker', '$model', '$lens', '$fl', '$fl35', '$apert', '$exposuretime', '$iso', '$flash', '$datetimeoriginal')"; + my $stmt = "INSERT OR REPLACE INTO photos (file, maker, model, lensmake, lens, focallength, focallength35mm, aperture, exposuretime, iso, flash, datetimeoriginal) + VALUES ('$file', '$maker', '$model', '$lensmake', '$lens', '$fl', '$fl35', '$apert', '$exposuretime', '$iso', '$flash', '$datetimeoriginal')"; my $rv = $dbh->do($stmt) or $errorcount++; } $dbh->disconnect(); @@ -253,7 +258,7 @@ sub main::HELP_MESSAGE say ' -g : group by time range, defaults to total (which means no grouping by time range)'; say ' allowed values: year, month, week, hour'; say ' -s : specify the information you want to select, defaults to none (just show number of images)'; - say ' allowed values: maker, model, lens, aperture, exposuretime, iso, focallength, focallength35mm'; + say ' allowed values: maker, model, lensmake, lens, aperture, exposuretime, iso, focallength, focallength35mm'; say ' multiple fields should be listed comma-separated'; say ' -t <range> : only take images into account which have been taken in the given timerange'; say ' <range> must be specified as \'YYYYMMDD-YYYYMMDD\', you can omit one value';