Image::Info - Extract meta information from image files |
Image::Info - Extract meta information from image files
use Image::Info qw(image_info dim);
my $info = image_info("image.jpg"); if (my $error = $info->{error}) { die "Can't parse image info: $error\n"; } my $color = $info->{color_type};
my($w, $h) = dim($info);
This module provide functions to extract various kind of meta
information from image files. The following functions are provided by
the Image::Info
module:
In case of error, and hash containing the ``error'' key will be returned. The corresponding value will be an appropriate error message.
If a reference to a scalar is passed as argument to this function, then it is assumed that this scalar contains the raw image data directly.
The image_info()
function also take optional key/value style arguments
that can influence what information is returned.
image_info()
and returns the dimensions
($width, $height) of the image. In scalar context returns the
dimensions as a string.
print "<img src="..." @{[html_dim($info)]}>\n";
The image_info()
function returns meta information about each image in
the form of a reference to a hash. The hash keys used are in most
cases based on the TIFF element names. All lower case keys are
mandatory for all file formats and will always be there unless an
error occured (in which case the ``error'' key will be present.) Mixed
case keys will only be present when the corresponding information
element is available in the image.
The following key names are common for any image format:
Gray GrayA RGB RGBA CMYK YCbCr CIELab
These names can also be prefixed by ``Indexed-'' if the image is composed of indexes into a palette. Of these, only ``Indexed-RGB'' is likely to occur.
(It is similar to the TIFF field PhotometricInterpretation, but this name was found to be too long, so we used the PNG inpired term instead.)
The syntax of this field is:
<res> <unit> <xres> "/" <yres> <unit> <xres> "/" <yres>
The <res>, <xres> and <yres> fields are numbers. The <unit> is a
string like dpi
, dpm
or dpcm
(denoting ``dots per
inch/cm/meter).
color_type
.
SamplesPerPixel
.
The following image file formats are currently supported:
For more information see the Image::Info::BMP manpage.
GIF_Version
for the first image. GIF files can contain multiple
images, and information for all images will be returned if
image_info()
is called in list context. The Netscape-2.0 extention to
loop animation sequences is represented by the GIF_Loop
key for the
first image. The value is either ``forever'' or a number indicating
loop count.
JFIF
and Exif
application chunks.
Exif
is the file format written by most digital cameras. This
encode things like timestamp, camera model, focal length, exposure
time, aperture, flash usage, GPS position, etc. The following web
page contain description of the fields that can be present:
http://www.ba.wakwak.com/~tsuruzoh/Computer/Digicams/exif-e.html
The Exif
spec can be found at:
http://www.pima.net/standards/it10/PIMA15740/exif.htm
PNG_Chunks
key.
TIFF
spec can be found at:
http://partners.adobe.com/asn/developer/PDFS/TN/TIFF6.pdf
Also good writeup on exif spec at: http://www.ba.wakwak.com/~tsuruzoh/Computer/Digicams/exif-e.html
Copyright 1999-2004 Gisle Aas.
GIF fixes by Ralf Steines <metamonk@yahoo.com>.
ASCII, BMP SVG, XPM and XBM support added by Jerrad Pierce
<belg4mit@mit.edu>/
Exif MakerNote decoding by Jay Soffian <jay@loudcloud.com>.
TIFF support by <clarsen@emf.net>.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Image::Info - Extract meta information from image files |