photo-stats

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

commit 8ca3d878c8103c1bb0c66b46fc1b192585700e3b
parent b82897ccead15155d95b899705a3e4fbf6ed3d7d
Author: René Wagner <rwagner@rw-net.de>
Date:   Wed, 29 Jul 2020 17:00:04 +0200

pretty print for exposure time

Diffstat:
Mphosta.pl | 14+++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/phosta.pl b/phosta.pl @@ -6,6 +6,8 @@ use warnings; use strict; use feature qw(say); +use POSIX qw(lround); +use Scalar::Util qw(looks_like_number); use Cwd; use DBI; use File::Basename; @@ -47,7 +49,7 @@ sub get_stats say "Scanning $destination_dir for files..."; - my $cmd = "exiftool -r -m -f -p '\$filepath##\$make##\$model##\$lens##\$lensmodel##\$focallength##\$focallengthin35mmformat##\$aperture##\$shutterspeed##\$iso##\$flash##\$datetimeoriginal' -d \"%Y-%m-%d %H:%M:%S\" -ext jpg " . $destination_dir; + my $cmd = "exiftool -r -m -f -p '\$filepath##\$make##\$model##\$lens##\$lensmodel##\$focallength##\$focallengthin35mmformat##\$aperture##\$exposuretime##\$iso##\$flash##\$datetimeoriginal##\$createdate' -d \"%Y-%m-%d %H:%M:%S\" -ext jpg " . $destination_dir; my @lines = qx($cmd); my $dbh = DBI->connect($dsn, $userid, $password, { RaiseError => 1 }) @@ -58,13 +60,15 @@ sub get_stats foreach (@lines) { chomp $_; - my ( $file, $maker, $model, $lens, $lensmodel, $fl, $fl35, $apert, $ss, $iso, $flash, $date ) = split(/#/, $_); - $lens = ($lens ne '-') ? $lens : $lensmodel; + my ( $file, $maker, $model, $lens, $lensmodel, $fl, $fl35, $apert, $exposuretime, $iso, $flash, $datetimeoriginal, $createdate ) = split(/#/, $_); - if ($date eq '-' || $model eq '-') { $emptycount++; next; } + if ($model eq '-') { $emptycount++; next; } + $lens = ($lens ne '-') ? $lens : $lensmodel; + if ($datetimeoriginal eq '0000:00:00 00:00:00') { $datetimeoriginal = $createdate; } + $exposuretime = (looks_like_number($exposuretime) && $exposuretime < 1) ? "1/". POSIX::lround(1/$exposuretime) : $exposuretime; 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')"; + VALUES ('$file', '$maker', '$model', '$lens', '$fl', '$fl35', '$apert', '$exposuretime', '$iso', '$flash', '$datetimeoriginal')"; my $rv = $dbh->do($stmt) or $errorcount++; } $dbh->disconnect();