-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloglens.pl
More file actions
executable file
·61 lines (52 loc) · 1.27 KB
/
loglens.pl
File metadata and controls
executable file
·61 lines (52 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#! /usr/bin/perl -w
use strict;
use Getopt::Long;
use Image::ExifTool ':Public';
#MaxApertureValue & EffectiveMaxAperture both seem to give max,
#with some rounding error.
my %opt;
GetOptions (\%opt, 'verbose!', 'summary!', 'lens=s') or die;
my @tags=('Lens', 'FocalLength');
my $type='ValueConv';
my %lenscount;
my $exiftool = Image::ExifTool->new;
$exiftool->Options(FastScan=>1);
$exiftool->Options(Composite=>0); #def ShutterSpeed is a composite
#foreach my $image (@ARGV){
while (my $image = <>) {
chomp $image;
my $info = $exiftool->ExtractInfo($image);
my $lens;
foreach my $tag (@tags) {
my $val = $exiftool->GetValue($tag,$type);
unless (defined $val) {
#warn "no lens for $image";
next;
}
if ($tag eq 'Lens') {
my @lens = split ' ', $val;
if ($lens[0] eq $lens[1]) {
$val = $lens[0];
} else {
$val = "$lens[0]-$lens[1]";
}
$val .= " f/";
if ($lens[2] eq $lens[3]) {
$val .= $lens[2];
} else {
$val .= "$lens[2]-$lens[3]";
}
$lenscount{$val} ++;
$lens = $val;
}
elsif ($tag eq 'FocalLength' and
!defined($opt{lens}) or $lens eq $opt{lens}) {
print "$lens\t$val\n";
}
}
}
if ($opt{summary}){
while (my ($lens, $count) = each %lenscount) {
print "$lens\t$count\n";
}
}