• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

etc/H28-Feb-2015-779755

ex/H28-Feb-2015-9880

lib/Image/H28-Feb-2015-1,469668

t/H03-May-2022-14482

xt/H28-Feb-2015-150104

ChangeLogH A D28-Feb-201521.5 KiB629476

ChangeLog.xmlH A D28-Feb-201537.9 KiB989987

MANIFESTH A D28-Feb-2015556 4140

MANIFEST.SKIPH A D28-Feb-2015106 1211

META.jsonH A D28-Feb-20151.3 KiB5958

META.ymlH A D28-Feb-2015840 3231

Makefile.PLH A D28-Feb-2015491 2018

READMEH A D28-Feb-20153.8 KiB13585

README.textileH A D28-Feb-20153.9 KiB11371

imgsizeH A D28-Feb-20154.5 KiB20564

README

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

README.textile

1h1. Image::Size - Determine the size of images in several common formats
2
3Version: 3.300 (See CHANGES below)
4
5h2. WHAT IS IT
6
7Image::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, MNG, TIFF, the PPM family of formats (PPM/PGM/PBM) and if Image::Magick is installed, the formats supported by it.
8
9I 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.
10
11
12h2. USING Image::Size IN YOUR SCRIPTS
13
14Image::Size has pod documentation that gives a more complete overview, but in a nutshell:
15
16<pre>
17<code>
18        use Image::Size;
19
20        ($x, $y) = imgsize("something.gif");
21</code>
22</pre>
23
24And <code>($x, $y)</code> 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:
25
26<pre>
27<code>
28        use CGI ':all';
29        use Image::Size 'attr_imgsize';
30
31        #
32        # Emit an IMG tag with size attributes:
33        #
34        print img({-SRC => '/server/images/arrow.gif',
35                   attr_imgsize('/server_root/server/images/arrow.gif')});
36</code>
37</pre>
38
39Alternately, if you are running under Apache and mod_perl:
40
41<pre>
42<code>
43        # Assume $Q is an object of class CGI, $r is an Apache request object
44        $r->print($Q->img({ -src => $imgpath,
45                            attr_imgsize($r->lookup_uri($imgpath)->
46                                         filename) }));
47</code>
48</pre>
49
50h2. BUILDING/INSTALLING
51
52This package uses Makefile.PL:
53
54<pre>
55<code>
56        perl Makefile.PL
57        make && make test
58        make install
59</code>
60</pre>
61
62You may need super-user access to install.
63
64
65h2. PROBLEMS/BUG REPORTS
66
67Please send any reports of problems or bugs to rjray@blackperl.com.
68
69
70h2. CHANGES
71
72* lib/Image/Size.pm
73* t/all.t
74* t/old-os2.bmp (added)
75
76p{margin-bottom:2em}. Add support for old OS/2 version of BMP header (Geoff Richards).
77
78* lib/Image/Size.pm
79
80p{margin-bottom:2em}. Typo fixes (David Steinbrunner).
81
82* lib/Image/Size.pm
83
84p{margin-bottom:2em}. 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).
85
86* lib/Image/Size.pm
87
88p{margin-bottom:2em}. Added =encoding utf8 to pod - the accented character was causing a pod error (Neil Bowers).
89
90* lib/Image/Size.pm
91
92p{margin-bottom:2em}. 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).
93
94* lib/Image/Size.pm
95
96p{margin-bottom:2em}. Added link to github repo to doc (Neil Bowers).
97
98* lib/Image/Size.pm
99
100p{margin-bottom:2em}. RT #41238: Applied modified version of patch from user to fix a die problem with unpack on truncated files.
101
102* lib/Image/Size.pm
103* t/1.sm.webp (added)
104* t/all.t
105* t/move.cur (added)
106* t/tux.ico (added)
107
108p{margin-bottom:2em}. Add support for WEBP, ICO and CUR file types (Baldur Kristinsson).
109
110* lib/Image/Size.pm
111
112p{margin-bottom:2em}. Fix some perlcritic issues.
113