Image::Size - Determine the size of images in several common formats Version: 2.902 (See CHANGES below) WHAT IS IT Image::Size is a library based on the image-sizing code in the wwwimagesize script, a tool that analyzes HTML files and adds HEIGHT and WIDTH tags to IMG directives. Image::Size has generalized that code to return a raw (X, Y) pair, and included wrappers to pre-format that output into either HTML or a set of attribute pairs suitable for the CGI.pm library by Lincoln Stein. Currently, Image::Size can size images in XPM, XBM, GIF, JPEG, PNG, TIFF and the PPM family of formats (PPM/PGM/PBM). I did this because my old WWW server generated a lot of documents on demand rather than keeping them in static files. These documents not only used directional icons and buttons, but other graphics to annotate and highlight sections of the text. Without size attributes, browsers cannot render the text of a page until the image data is loaded and the size known for layout. This library enables scripts to size their images at run-time and include that as part of the generated HTML. Or for any other utility that uses and manipulates graphics. The idea of the basic interface + wrappers is to not limit the programmer to a certain data format. USING Image::Size IN YOUR SCRIPTS Image::Size has pod documentation that gives a more complete overview, but in a nutshell: use Image::Size; ($x, $y) = imgsize("something.gif"); And ($x, $y) is now the width and height of something.gif. 95% of my usage of this library is in conjunction with Lincoln Stein's CGI.pm: use CGI ':all'; use Image::Size 'attr_imgsize'; # # Emit an IMG tag with size attributes: # print img({-SRC => '/server/images/arrow.gif', attr_imgsize('/server_root/server/images/arrow.gif')}); Alternately, if you are running under Apache and mod_perl: # Assume $Q is an object of class CGI, $r is an Apache request object $r->print($Q->img({ -src => $imgpath, attr_imgsize($r->lookup_uri($imgpath)-> filename) })); BUILDING/INSTALLING This package is set up to configure and build like a typical Perl extension. To build: perl Makefile.PL make && make test If Image::Size passes all tests, then: make install You may need super-user access to install. PROBLEMS/BUG REPORTS Please send any reports of problems or bugs to rjray@tsoft.com. CHANGES This is version 2.902: * Added a file, README.Win32, with special instructions for users on systems that lack MakeMaker support. * Worked on the regular expressions that are used on the text-based formats, in hopes of further smoothing out the rift between UNIX and non-UNIX systems. * Added use of Cwd. Filenames passed in are prepended with the current dir if they aren't already absolute pathnames. This was to fix a subtle problem where different files with the same relative names (referenced from different directories) would confuse the cache. * Added the image type to the cached data. Previously, only dimensions were cached. Now, a cache-hit returns the same triple returned originally. * Also added the file's modification-time to the cache, as the (growing!) use of Image::Size in Apache mod_perl environments found that if an image is changed, the cache won't notice. Now it does. * Added recognition of thumbnail-format pics from the popular viewer XV. The value of image type for these is the string "XV". * Integrated a patch that makes html_imgsize generate tags that are XHTML- compliant. Same patch also caught a few doc bugs that I'd missed. * Added more to the README file and the pod documentation, particularly dealing with the Apache web server. * Moved the full change history to a separate file. CREDITS AND LICENSES This package is copyright © 1996,1998 by Randy Ray (rjray@tsoft.com) and may be distributed under terms of the Artistic License used to cover Perl itself. See the file Artistic in the distribution of Perl 5.002 or later for details of copy and distribution terms. Perl module interface by Randy J. Ray (rjray@tsoft.com), original image-sizing code by Alex Knowles (alex@ed.ac.uk) and Andrew Tong (werdna@ugcs.caltech.edu), used with their joint permission. Some bug fixes submitted by Bernd Leibing . PPM/PGM/PBM sizing code contributed by Carsten Dominik . Tom Metro re-wrote the JPG and PNG code, and also provided a PNG image for the test suite. Dan Klein contributed a re-write of the GIF code. Cloyce Spradling contributed the TIFF sizing code and test images. A fix for reading binary data on PC-ish operating systems was contributed by Silas Dunsmore . Aldo Calpini sent in code that was easily adapted to support BMP images (Windows bitmaps). Fix for a recurring problem with GIF87a files contributed by Matthias Schmitt . Fix for problems with PPM formats on some Win32 versions was contributed by Randy Kobes . The tip leading to support for XV's thumbnail pics format came from . A patch to allow html_imgsize to produce valid output for XHTML, as well as some documentation fixes was provided by Charles Levert .