#!/usr/bin/perl ########################################### # iinfo # Mike Schilli, 2002 (m@perlmeister.com) ########################################### use Pod::Usage; use Image::Info qw(image_info); use Data::Dumper; use Getopt::Std; our $CVSVERSION = '$Revision: 1.3 $'; getopts("f:", \my %opts); my($file) = @ARGV; if(! defined $file) { pod2usage("No image file specified"); } unless(-f $file and -r $file) { pod2usage("$file not a file or not readable"); } my $info = image_info($file); if (my $error = $info->{error}) { pod2usage "Can't parse image info for $file: $error"; } if(exists $opts{f}) { if(exists $info->{$opts{f}}) { print "$info->{$opts{f}}\n"; } else { print "No entry found for $opts{f}\n"; } exit 0; } for (keys %$info) { delete $info->{$_} if $info->{$_} =~ /[^[:print:]]/ or ref $info->{$key}; } my $maxkey = 0; for my $key (keys %$info) { $maxkey = length($key) if length($key) > $maxkey; } $maxkey += 5; for my $key (keys %$info) { print $key; print " " . ("." x ($maxkey-length($key)-2)) . " "; print "$info->{$key}\n"; } __END__ =head1 NAME iinfo - Extracts and displays image text data =head1 DOWNLOAD _SRC_HERE_ =head1 SYNOPSIS iinfo image iinfo -f fieldname image =head1 DESCRIPTION B takes an image file as an argument and tries to read its meta text data. Many image file formats allow for additional information to be attached to the otherwise binary image data. =head1 EXAMPLES $ iinfo dcsf002002.jpg DateTime ................... 2002:01:20 10:38:02 file_media_type ............ image/jpeg CompressedBitsPerPixel ..... 20/10 ExposureBiasValue .......... 0/100 ExposureTime ............... 10/800 ISOSpeedRatings ............ 100 Model ...................... FinePix2650 LightSource ................ unknown FileSource ................. (DSC) Digital Still Camera MeteringMode ............... Pattern ... $ iinfo -f DateTime dcsf002002.jpg 2002:01:20 10:38:02 =head1 GOTCHAS The Image::Info module also returns hash entries which in turn contain nested data structures. All of these are I by iinfo for compactness. =head1 LEGALESE Copyright 2003 by Mike Schilli, all rights reserved. This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =head1 AUTHOR 2003, Mike Schilli