6 use Getopt::Long '2.33', qw( :config gnu_getopt );
13 require Image::ExifTool;
14 my $exif = Image::ExifTool->new->ImageInfo($file, {
15 CoordFormat => '%.5f',
16 DateFormat => '%Y-%m-%d %H:%M:%S',
17 Exclude => 'System:*',
19 die "exiftool: $exif->{Error}\n" if $exif->{Error};
22 $exif->{ImageSize} ? "$exif->{ImageSize} ($exif->{Megapixels}MP)" : (),
24 $exif->{YCbCrSubSampling} // (),
25 $exif->{Interlace} // (),
26 $exif->{Compression} // $exif->{FileType},
27 $exif->{SVGVersion} // $exif->{PDFVersion} // (),
29 $exif->{ColorType} ? "$exif->{BitDepth}bpp $exif->{ColorType}" : (),
32 sprintf('(%d)', scalar %{$exif}),
34 $exif->{Thumb} ? "thumb $exif->{ThumbnailLength}B" : (),
36 $exif->{DateTimeOriginal} //
37 $exif->{DateCreated} //
38 $exif->{CircaDateCreated} //
39 $exif->{ModifyDate} //
40 $exif->{ZipModifyDate} //
44 $exif->{GPSPosition} // $exif->{Location} // (),
45 $exif->{GPSAltitude} // (),
47 (map "hw $_", join(' ',
48 $exif->{Make} // (), $exif->{Model} // (),
49 $exif->{FOV} ? "(FOV $exif->{FOV})" : (),
51 (map "sw $_", $exif->{Software} // $exif->{Application} // ()),
52 (map "> $_", $exif->{'Description-nl'} // ()),
53 $exif->{Warning} ? "! $exif->{Warning}" : (),
58 my $filesize = (stat $file)[7];
61 open my $bin, '<', $file;
63 my $md5 = Digest::MD5->new->addfile($bin)->b64digest;
64 push @info, "# $md5 ($filesize)";
68 require Term::ReadKey;
69 my ($w, $h, $x, $y) = Term::ReadKey::GetTerminalSize();
73 open my $pgm, '-|', convert => (
76 $aspect ? ('+distort' => SRT => "0,0 1,$aspect 0") : (),
77 -thumbnail => $opt{size} || '40x12',
78 -colorspace => 'gray',
81 -channel => 'A', -threshold => '50%',
82 -background => 'black',
88 if (<$pgm> eq "P2\n") {
89 my ($width, $height) = split ' ', <$pgm>;
90 <$pgm>; # ignore depth
91 my @ch = split //, " .:oO@";
93 print !$_ ? '/' : $ch[ $_ * @ch >> 8 ] for /\d+/g;
94 print ' ', shift @info if @info;
97 substr $_, 0, 0, ' ' x ($width + 1) for @info;
103 termimg - media file fingerprint and metadata
107 B<termimg> [<options>] <file>
111 Identify given file by ascii image
112 with a summary of distinctive metadata.
118 =item -s, --size=<width>x<height>
124 Mischa POSLAWSKY <perl@shiar.org>