| 1 |
Image::Size - Determine the size of images in several common formats |
| 2 |
==================================================================== |
| 3 |
|
| 4 |
Version: 3.300 (See CHANGES below) |
| 5 |
|
| 6 |
|
| 7 |
WHAT IS IT |
| 8 |
---------- |
| 9 |
|
| 10 |
Image::Size is a library based on the image-sizing code in the wwwimagesize |
| 11 |
script, a tool that analyzes HTML files and adds HEIGHT and WIDTH tags to IMG |
| 12 |
directives. Image::Size has generalized that code to return a raw (X, Y) pair, |
| 13 |
and included wrappers to pre-format that output into either HTML or a set of |
| 14 |
attribute pairs suitable for the CGI.pm library by Lincoln Stein. Currently, |
| 15 |
Image::Size can size images in XPM, XBM, GIF, JPEG, PNG, MNG, TIFF, the PPM |
| 16 |
family of formats (PPM/PGM/PBM) and if Image::Magick is installed, the formats |
| 17 |
supported by it. |
| 18 |
|
| 19 |
I did this because my old WWW server generated a lot of documents on demand |
| 20 |
rather than keeping them in static files. These documents not only used |
| 21 |
directional icons and buttons, but other graphics to annotate and highlight |
| 22 |
sections of the text. Without size attributes, browsers cannot render the text |
| 23 |
of a page until the image data is loaded and the size known for layout. This |
| 24 |
library enables scripts to size their images at run-time and include that as |
| 25 |
part of the generated HTML. Or for any other utility that uses and manipulates |
| 26 |
graphics. The idea of the basic interface + wrappers is to not limit the |
| 27 |
programmer to a certain data format. |
| 28 |
|
| 29 |
|
| 30 |
USING Image::Size IN YOUR SCRIPTS |
| 31 |
--------------------------------- |
| 32 |
|
| 33 |
Image::Size has pod documentation that gives a more complete overview, but in a |
| 34 |
nutshell: |
| 35 |
|
| 36 |
use Image::Size; |
| 37 |
|
| 38 |
($x, $y) = imgsize("something.gif"); |
| 39 |
|
| 40 |
And ($x, $y) is now the width and height of something.gif. 95% of my usage of |
| 41 |
this library is in conjunction with Lincoln Stein's CGI.pm: |
| 42 |
|
| 43 |
use CGI ':all'; |
| 44 |
use Image::Size 'attr_imgsize'; |
| 45 |
|
| 46 |
# |
| 47 |
# Emit an IMG tag with size attributes: |
| 48 |
# |
| 49 |
print img({-SRC => '/server/images/arrow.gif', |
| 50 |
attr_imgsize('/server_root/server/images/arrow.gif')}); |
| 51 |
|
| 52 |
Alternately, if you are running under Apache and mod_perl: |
| 53 |
|
| 54 |
# Assume $Q is an object of class CGI, $r is an Apache request object |
| 55 |
$r->print($Q->img({ -src => $imgpath, |
| 56 |
attr_imgsize($r->lookup_uri($imgpath)-> |
| 57 |
filename) })); |
| 58 |
|
| 59 |
|
| 60 |
BUILDING/INSTALLING |
| 61 |
------------------- |
| 62 |
|
| 63 |
This package uses Makefile.PL: |
| 64 |
|
| 65 |
perl Makefile.PL |
| 66 |
make && make test |
| 67 |
make install |
| 68 |
|
| 69 |
You may need super-user access to install. |
| 70 |
|
| 71 |
|
| 72 |
PROBLEMS/BUG REPORTS |
| 73 |
-------------------- |
| 74 |
|
| 75 |
Please send any reports of problems or bugs to [email protected]. |
| 76 |
|
| 77 |
|
| 78 |
CHANGES |
| 79 |
------- |
| 80 |
|
| 81 |
* lib/Image/Size.pm |
| 82 |
|
| 83 |
* t/all.t |
| 84 |
|
| 85 |
* t/old-os2.bmp (added) |
| 86 |
|
| 87 |
Add support for old OS/2 version of BMP header (Geoff Richards). |
| 88 |
|
| 89 |
* lib/Image/Size.pm |
| 90 |
|
| 91 |
Typo fixes (David Steinbrunner). |
| 92 |
|
| 93 |
* lib/Image/Size.pm |
| 94 |
|
| 95 |
Avoid a sprintf() warning in Perl 5.21. Perl 5.21 introduces a warning for |
| 96 |
redundant arguments to s?printf(), so sprintf("%d", 1, 2) would warn. This |
| 97 |
commit silences that warning by passing sprintf the exact number of arguments |
| 98 |
that it expects (Brian Fraser). |
| 99 |
|
| 100 |
* lib/Image/Size.pm |
| 101 |
|
| 102 |
Added =encoding utf8 to pod - the accented character was causing a pod error |
| 103 |
(Neil Bowers). |
| 104 |
|
| 105 |
* lib/Image/Size.pm |
| 106 |
|
| 107 |
Added Z<> to the =item [012] to resolve pod warning. You can't have =item 0, so |
| 108 |
the way round this seems to be to add a Z<> (zero width space) before each digit |
| 109 |
(Neil Bowers). |
| 110 |
|
| 111 |
* lib/Image/Size.pm |
| 112 |
|
| 113 |
Added link to github repo to doc (Neil Bowers). |
| 114 |
|
| 115 |
* lib/Image/Size.pm |
| 116 |
|
| 117 |
RT #41238: Applied modified version of patch from user to fix a die problem with |
| 118 |
unpack on truncated files. |
| 119 |
|
| 120 |
* lib/Image/Size.pm |
| 121 |
|
| 122 |
* t/1.sm.webp (added) |
| 123 |
|
| 124 |
* t/all.t |
| 125 |
|
| 126 |
* t/move.cur (added) |
| 127 |
|
| 128 |
* t/tux.ico (added) |
| 129 |
|
| 130 |
Add support for WEBP, ICO and CUR file types (Baldur Kristinsson). |
| 131 |
|
| 132 |
* lib/Image/Size.pm |
| 133 |
|
| 134 |
Fix some perlcritic issues. |