Image-Size  3.300
About: Image-Size determines the size of images in several common formats for e.g. it can add HEIGHT and WIDTH tags to HTML IMG directives (Perl module).
  Fossies Dox: Image-Size-3.300.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

No Matches
Image-Size Documentation

Some Fossies usage hints in advance:

  1. To see the Doxygen generated documentation please click on one of the items in the steelblue colored "quick index" bar above or use the side panel at the left which displays a hierarchical tree-like index structure and is adjustable in width.
  2. If you want to search for something by keyword rather than browse for it you can use the client side search facility (using Javascript and DHTML) that provides live searching, i.e. the search results are presented and adapted as you type in the Search input field at the top right.
  3. Doxygen doesn't incorporate all member files but just a definable subset (basically the main project source code files that are written in a supported language). So to search and browse all member files you may visit the Fossies Image-Size-3.300.tar.gz contents page and use the Fossies standard member browsing features (also with source code highlighting and additionally with optional code folding).

Image::Size - Determine the size of images in several common formats

Version: 3.300 (See CHANGES below)


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 library by Lincoln Stein. Currently, Image::Size can size images in XPM, XBM, GIF, JPEG, PNG, MNG, TIFF, the PPM family of formats (PPM/PGM/PBM) and if Image::Magick is installed, the formats supported by it.

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.


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

    use CGI ':all';
    use Image::Size 'attr_imgsize';

    # Emit an IMG tag with size attributes:
    print img({-SRC => '/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,
                                     filename) }));


This package uses Makefile.PL:

    perl Makefile.PL
    make && make test
    make install

You may need super-user access to install.


Please send any reports of problems or bugs to


  • lib/Image/

  • t/all.t

  • t/old-os2.bmp (added)

Add support for old OS/2 version of BMP header (Geoff Richards).

  • lib/Image/

Typo fixes (David Steinbrunner).

  • lib/Image/

Avoid a sprintf() warning in Perl 5.21. Perl 5.21 introduces a warning for redundant arguments to s?printf(), so sprintf("%d", 1, 2) would warn. This commit silences that warning by passing sprintf the exact number of arguments that it expects (Brian Fraser).

  • lib/Image/

Added =encoding utf8 to pod - the accented character was causing a pod error (Neil Bowers).

  • lib/Image/

Added Z<> to the =item [012] to resolve pod warning. You can't have =item 0, so the way round this seems to be to add a Z<> (zero width space) before each digit (Neil Bowers).

  • lib/Image/

Added link to github repo to doc (Neil Bowers).

  • lib/Image/

RT #41238: Applied modified version of patch from user to fix a die problem with unpack on truncated files.

  • lib/Image/

  • t/ (added)

  • t/all.t

  • t/move.cur (added)

  • t/tux.ico (added)

Add support for WEBP, ICO and CUR file types (Baldur Kristinsson).

  • lib/Image/

Fix some perlcritic issues.