1Image::Info(3)        User Contributed Perl Documentation       Image::Info(3)
2
3
4

NAME

6       Image::Info - Extract meta information from image files (DEPRECATED)
7

SYNOPSIS

9        use Image::Info qw(image_info dim);
10
11        my $info = image_info("image.jpg");
12        if (my $error = $info->{error}) {
13            die "Can't parse image info: $error\n";
14        }
15        my $color = $info->{color_type};
16
17        my $type = image_type("image.jpg");
18        if (my $error = $type->{error}) {
19            die "Can't determine file type: $error\n";
20        }
21        die "No gif files allowed!" if $type->{file_type} eq 'GIF';
22
23        my($w, $h) = dim($info);
24

DESCRIPTION

26       Please note that this module is deprecated and should not be used.
27       Alternatively, try one of the following modules:
28
29       Image::Size, Image::ExifTool.
30
31       The code in this module is old, unreviewed, hackish, still has numerous
32       bugs and is incomplete in quite a few cases.
33
34       While this module is sort-of maintained (e.g. the most critical
35       security-related bugs are fixed), no new features will be added and
36       numerous minor bugs are very likely sprinkled through the entire code
37       base. You have been warned.
38
39       This module provide functions to extract various kind of meta
40       information from image files.
41
42   EXPORTS
43       Exports nothing by default, but can export the following methods on
44       request:
45
46               image_info
47               image_type
48               dim
49               html_dim
50               determine_file_type
51
52   METHODS
53       The following functions are provided by the "Image::Info" module:
54
55       image_info( $file )
56       image_info( \$imgdata )
57       image_info( $file, key => value,... )
58           This function takes the name of a file or a file handle as argument
59           and will return one or more hashes (actually hash references)
60           describing the images inside the file.  If there is only one image
61           in the file only one hash is returned.  In scalar context, only the
62           hash for the first image is returned.
63
64           In case of error, and hash containing the "error" key will be
65           returned.  The corresponding value will be an appropriate error
66           message.
67
68           If a reference to a scalar is passed as argument to this function,
69           then it is assumed that this scalar contains the raw image data
70           directly.
71
72           The image_info() function also take optional key/value style
73           arguments that can influence what information is returned.
74
75       image_type( \$imgdata )
76           Returns a hash with only one key, "file_type". The value will be
77           the type of the file. On error, sets the two keys "error" and
78           "Errno".
79
80           This function is a dramatically faster alternative to the
81           image_info function for situations in which you only need to find
82           the image type.
83
84           It uses only the internal file-type detection to do this, and thus
85           does not need to load any of the image type-specific driver
86           modules, and does not access to entire file. It also only needs
87           access to the first 11 bytes of the file.
88
89           To maintain some level of compatibility with image_info, image_type
90           returns in the same format, with the same error message style. That
91           is, it returns a HASH reference, with the "$type->{error}" key set
92           if there was an error.
93
94           On success, the HASH reference will contain the single key
95           'file_type', which represents the type of the file, expressed as
96           the type code used for the various drivers ('GIF', 'JPEG', 'TIFF'
97           and so on).
98
99           If there are multiple images within the file they will be ignored,
100           as this function provides only the type of the overall file, not of
101           the various images within it. This function will not return
102           multiple hashes if the file contains multiple images.
103
104           Of course, in all (or at least effectively all) cases the type of
105           the images inside the file is going to be the same as that of the
106           file itself.
107
108       dim( $info_hash )
109           Takes an hash as returned from image_info() and returns the
110           dimensions ($width, $height) of the image.  In scalar context
111           returns the dimensions as a string.
112
113       html_dim( $info_hash )
114           Returns the dimensions as a string suitable for embedding directly
115           into HTML or SVG <img>-tags. E.g.:
116
117              print "<img src="..." @{[html_dim($info)]}>\n";
118
119       determine_file_format( $filedata )
120           Determines the file format from the passed file data (a normal Perl
121           scalar containing the first bytes of the file), and returns either
122           undef for an unknown file format, or a string describing the
123           format, like "BMP" or "JPEG".
124

Image descriptions

126       The image_info() function returns meta information about each image in
127       the form of a reference to a hash.  The hash keys used are in most
128       cases based on the TIFF element names.  All lower case keys are
129       mandatory for all file formats and will always be there unless an error
130       occured (in which case the "error" key will be present.)  Mixed case
131       keys will only be present when the corresponding information element is
132       available in the image.
133
134       The following key names are common for any image format:
135
136       file_media_type
137           This is the MIME type that is appropriate for the given file
138           format.  The corresponding value is a string like: "image/png" or
139           "image/jpeg".
140
141       file_ext
142           The is the suggested file name extention for a file of the given
143           file format.  The value is a 3 letter, lowercase string like "png",
144           "jpg".
145
146       width
147           This is the number of pixels horizontally in the image.
148
149       height
150           This is the number of pixels vertically in the image.  (TIFF use
151           the name ImageLength for this field.)
152
153       color_type
154           The value is a short string describing what kind of values the
155           pixels encode.  The value can be one of the following:
156
157             Gray
158             GrayA
159             RGB
160             RGBA
161             CMYK
162             YCbCr
163             CIELab
164
165           These names can also be prefixed by "Indexed-" if the image is
166           composed of indexes into a palette.  Of these, only "Indexed-RGB"
167           is likely to occur.
168
169           It is similar to the TIFF field PhotometricInterpretation, but this
170           name was found to be too long, so we used the PNG inpired term
171           instead.
172
173       resolution
174           The value of this field normally gives the physical size of the
175           image on screen or paper. When the unit specifier is missing then
176           this field denotes the squareness of pixels in the image.
177
178           The syntax of this field is:
179
180              <res> <unit>
181              <xres> "/" <yres> <unit>
182              <xres> "/" <yres>
183
184           The <res>, <xres> and <yres> fields are numbers.  The <unit> is a
185           string like "dpi", "dpm" or "dpcm" (denoting "dots per
186           inch/cm/meter).
187
188       SamplesPerPixel
189           This says how many channels there are in the image.  For some image
190           formats this number might be higher than the number implied from
191           the "color_type".
192
193       BitsPerSample
194           This says how many bits are used to encode each of samples.  The
195           value is a reference to an array containing numbers. The number of
196           elements in the array should be the same as "SamplesPerPixel".
197
198       Comment
199           Textual comments found in the file.  The value is a reference to an
200           array if there are multiple comments found.
201
202       Interlace
203           If the image is interlaced, then this tell which interlace method
204           is used.
205
206       Compression
207           This tells you which compression algorithm is used.
208
209       Gamma
210           A number.
211
212       LastModificationTime
213           A ISO date string
214

Supported Image Formats

216       The following image file formats are supported:
217
218       BMP This module supports the Microsoft Device Independent Bitmap format
219           (BMP, DIB, RLE).
220
221           For more information see Image::Info::BMP.
222
223       GIF Both GIF87a and GIF89a are supported and the version number is
224           found as "GIF_Version" for the first image.  GIF files can contain
225           multiple images, and information for all images will be returned if
226           image_info() is called in list context.  The Netscape-2.0 extention
227           to loop animation sequences is represented by the "GIF_Loop" key
228           for the first image.  The value is either "forever" or a number
229           indicating loop count.
230
231       JPEG
232           For JPEG files we extract information both from "JFIF" and "Exif"
233           application chunks.
234
235           "Exif" is the file format written by most digital cameras.  This
236           encode things like timestamp, camera model, focal length, exposure
237           time, aperture, flash usage, GPS position, etc.  The following web
238           page contain description of the fields that can be present:
239
240            http://www.ba.wakwak.com/~tsuruzoh/Computer/Digicams/exif-e.html
241
242           The "Exif" spec can be found at:
243
244            http://www.exif.org/specifications.html
245
246       PNG Information from IHDR, PLTE, gAMA, pHYs, tEXt, tIME chunks are
247           extracted.  The sequence of chunks are also given by the
248           "PNG_Chunks" key.
249
250       PBM/PGM/PPM
251           All information available is extracted.
252
253       SVG Provides a plethora of attributes and metadata of an SVG vector
254           grafic.
255
256       TIFF
257           The "TIFF" spec can be found at:
258           <http://partners.adobe.com/public/developer/tiff/>
259
260           The EXIF spec can be found at: <http://www.exif.org/>
261
262       XBM See Image::Info::XBM for details.
263
264       XPM See Image::Info::XPM for details.
265

CAVEATS

267       Note that while the module is still maintained, no new features will be
268       added and numerous bugs remain throughout the code base.
269
270       Especially the EXIF parsing code is buggy, not tested at all, and quite
271       incomplete (a lot of manufacturer's MakerNotes and tags are not parsed
272       at all). If you want a stable, feature-complete, up-to-date and tested
273       EXIF parsing library, please use Image::ExifTool.
274
275       Likewise, the image parsing code is quite hackish and seems to contain
276       an endless supply of bugs that crash, or hang with malformed input.
277

SEE ALSO

279       Image::Size, Image::ExifTool
280

AUTHORS

282       Copyright 1999-2004 Gisle Aas.
283
284       See the CREDITS file for a list of contributors and authors.
285
286       Now maintained by Tels - (c) 2006 - 2008.
287

LICENSE

289       This library is free software; you can redistribute it and/or modify it
290       under the same terms as Perl v5.8.8 itself.
291
292
293
294perl v5.12.0                      2008-03-30                    Image::Info(3)
Impressum