Mini Shell
Direktori : /usr/local/share/man/man3/ |
|
Current File : //usr/local/share/man/man3/Template::Plugin::Image.3pm |
.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
. if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{\
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "Template::Plugin::Image 3"
.TH Template::Plugin::Image 3 "2024-06-21" "perl v5.32.1" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
Template::Plugin::Image \- Plugin access to image sizes
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 6
\& [% USE Image(filename) %]
\& [% Image.width %]
\& [% Image.height %]
\& [% Image.size.join(\*(Aq, \*(Aq) %]
\& [% Image.attr %]
\& [% Image.tag %]
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
This plugin provides an interface to the Image::Info or Image::Size
modules for determining the size of image files.
.PP
You can specify the plugin name as either '\f(CW\*(C`Image\*(C'\fR' or '\f(CW\*(C`image\*(C'\fR'. The
plugin object created will then have the same name. The file name of
the image should be specified as a positional or named argument.
.PP
.Vb 6
\& [% # all these are valid, take your pick %]
\& [% USE Image(\*(Aqfoo.gif\*(Aq) %]
\& [% USE image(\*(Aqbar.gif\*(Aq) %]
\& [% USE Image \*(Aqping.gif\*(Aq %]
\& [% USE image(name=\*(Aqbaz.gif\*(Aq) %]
\& [% USE Image name=\*(Aqpong.gif\*(Aq %]
.Ve
.PP
A \f(CW\*(C`root\*(C'\fR parameter can be used to specify the location of the image file:
.PP
.Vb 3
\& [% USE Image(root=\*(Aq/path/to/root\*(Aq, name=\*(Aqimages/home.png\*(Aq) %]
\& # image path: /path/to/root/images/home.png
\& # img src: images/home.png
.Ve
.PP
In cases where the image path and image url do not match up, specify the
file name directly:
.PP
.Vb 1
\& [% USE Image(file=\*(Aq/path/to/home.png\*(Aq, name=\*(Aq/images/home.png\*(Aq) %]
.Ve
.PP
The \f(CW\*(C`alt\*(C'\fR parameter can be used to specify an alternate name for the
image, for use in constructing an \s-1XHTML\s0 element (see the \f(CW\*(C`tag()\*(C'\fR method
below).
.PP
.Vb 1
\& [% USE Image(\*(Aqhome.png\*(Aq, alt="Home") %]
.Ve
.PP
You can also provide an alternate name for an \f(CW\*(C`Image\*(C'\fR plugin object.
.PP
.Vb 2
\& [% USE img1 = image \*(Aqfoo.gif\*(Aq %]
\& [% USE img2 = image \*(Aqbar.gif\*(Aq %]
.Ve
.PP
The \f(CW\*(C`name\*(C'\fR method returns the image file name.
.PP
.Vb 1
\& [% img1.name %] # foo.gif
.Ve
.PP
The \f(CW\*(C`width\*(C'\fR and \f(CW\*(C`height\*(C'\fR methods return the width and height of the
image, respectively. The \f(CW\*(C`size\*(C'\fR method returns a reference to a 2
element list containing the width and height.
.PP
.Vb 4
\& [% USE image \*(Aqfoo.gif\*(Aq %]
\& width: [% image.width %]
\& height: [% image.height %]
\& size: [% image.size.join(\*(Aq, \*(Aq) %]
.Ve
.PP
The \f(CW\*(C`modtime\*(C'\fR method returns the modification time of the file in question,
suitable for use with the Date plugin, for example:
.PP
.Vb 3
\& [% USE image \*(Aqfoo.gif\*(Aq %]
\& [% USE date %]
\& [% date.format(image.modtime, "%B, %e %Y") %]
.Ve
.PP
The \f(CW\*(C`attr\*(C'\fR method returns the height and width as \s-1HTML/XML\s0 attributes.
.PP
.Vb 2
\& [% USE image \*(Aqfoo.gif\*(Aq %]
\& [% image.attr %]
.Ve
.PP
Typical output:
.PP
.Vb 1
\& width="60" height="20"
.Ve
.PP
The \f(CW\*(C`tag\*(C'\fR method returns a complete \s-1XHTML\s0 tag referencing the image.
.PP
.Vb 2
\& [% USE image \*(Aqfoo.gif\*(Aq %]
\& [% image.tag %]
.Ve
.PP
Typical output:
.PP
.Vb 1
\& <img src="foo.gif" width="60" height="20" alt="" />
.Ve
.PP
You can provide any additional attributes that should be added to the
\&\s-1XHTML\s0 tag.
.PP
.Vb 2
\& [% USE image \*(Aqfoo.gif\*(Aq %]
\& [% image.tag(class="logo" alt="Logo") %]
.Ve
.PP
Typical output:
.PP
.Vb 1
\& <img src="foo.gif" width="60" height="20" alt="Logo" class="logo" />
.Ve
.PP
Note that the \f(CW\*(C`alt\*(C'\fR attribute is mandatory in a strict \s-1XHTML\s0 \f(CW\*(C`img\*(C'\fR
element (even if it's empty) so it is always added even if you don't
explicitly provide a value for it. You can do so as an argument to
the \f(CW\*(C`tag\*(C'\fR method, as shown in the previous example, or as an argument
.PP
.Vb 1
\& [% USE image(\*(Aqfoo.gif\*(Aq, alt=\*(AqLogo\*(Aq) %]
.Ve
.SH "CATCHING ERRORS"
.IX Header "CATCHING ERRORS"
If the image file cannot be found then the above methods will throw an
\&\f(CW\*(C`Image\*(C'\fR error. You can enclose calls to these methods in a
\&\f(CW\*(C`TRY...CATCH\*(C'\fR block to catch any potential errors.
.PP
.Vb 6
\& [% TRY;
\& image.width;
\& CATCH;
\& error; # print error
\& END
\& %]
.Ve
.SH "USING Image::Info"
.IX Header "USING Image::Info"
At run time, the plugin tries to load Image::Info in preference to
Image::Size. If Image::Info is found, then some additional methods are
available, in addition to \f(CW\*(C`size\*(C'\fR, \f(CW\*(C`width\*(C'\fR, \f(CW\*(C`height\*(C'\fR, \f(CW\*(C`attr\*(C'\fR, and \f(CW\*(C`tag\*(C'\fR.
These additional methods are named after the elements that Image::Info
retrieves from the image itself. The types of methods available depend on the
type of image (see Image::Info for more details). These additional methods
will always include the following:
.SS "file_media_type"
.IX Subsection "file_media_type"
This is the \s-1MIME\s0 type that is appropriate for the given file format.
The corresponding value is a string like: "\f(CW\*(C`image/png\*(C'\fR\*(L" or \*(R"\f(CW\*(C`image/jpeg\*(C'\fR".
.SS "file_ext"
.IX Subsection "file_ext"
The is the suggested file name extension for a file of the given
file format. The value is a 3 letter, lowercase string like
"\f(CW\*(C`png\*(C'\fR\*(L", \*(R"\f(CW\*(C`jpg\*(C'\fR".
.SS "color_type"
.IX Subsection "color_type"
The value is a short string describing what kind of values the pixels
encode. The value can be one of the following:
.PP
.Vb 7
\& Gray
\& GrayA
\& RGB
\& RGBA
\& CMYK
\& YCbCr
\& CIELab
.Ve
.PP
These names can also be prefixed by "\f(CW\*(C`Indexed\-\*(C'\fR\*(L" if the image is
composed of indexes into a palette. Of these, only \*(R"\f(CW\*(C`Indexed\-RGB\*(C'\fR" is
likely to occur.
.PP
(It is similar to the \s-1TIFF\s0 field PhotometricInterpretation, but this
name was found to be too long, so we used the \s-1PNG\s0 inspired term
instead.)
.SS "resolution"
.IX Subsection "resolution"
The value of this field normally gives the physical size of the image
on screen or paper. When the unit specifier is missing then this field
denotes the squareness of pixels in the image.
.PP
The syntax of this field is:
.PP
.Vb 3
\& <res> <unit>
\& <xres> "/" <yres> <unit>
\& <xres> "/" <yres>
.Ve
.PP
The \f(CW\*(C`<res>\*(C'\fR, \f(CW\*(C`<xres>\*(C'\fR and \f(CW\*(C`<yres>\*(C'\fR fields are
numbers. The \f(CW\*(C`<unit>\*(C'\fR is a string like \f(CW\*(C`dpi\*(C'\fR, \f(CW\*(C`dpm\*(C'\fR or
\&\f(CW\*(C`dpcm\*(C'\fR (denoting "dots per inch/cm/meter).
.SS "SamplesPerPixel"
.IX Subsection "SamplesPerPixel"
This says how many channels there are in the image. For some image
formats this number might be higher than the number implied from the
\&\f(CW\*(C`color_type\*(C'\fR.
.SS "BitsPerSample"
.IX Subsection "BitsPerSample"
This says how many bits are used to encode each of samples. The value
is a reference to an array containing numbers. The number of elements
in the array should be the same as \f(CW\*(C`SamplesPerPixel\*(C'\fR.
.SS "Comment"
.IX Subsection "Comment"
Textual comments found in the file. The value is a reference to an
array if there are multiple comments found.
.SS "Interlace"
.IX Subsection "Interlace"
If the image is interlaced, then this returns the interlace type.
.SS "Compression"
.IX Subsection "Compression"
This returns the name of the compression algorithm is used.
.SS "Gamma"
.IX Subsection "Gamma"
A number indicating the gamma curve of the image (e.g. 2.2)
.SH "AUTHOR"
.IX Header "AUTHOR"
Andy Wardley <abw@wardley.org> <http://wardley.org/>
.SH "COPYRIGHT"
.IX Header "COPYRIGHT"
Copyright (C) 1996\-2022 Andy Wardley. All Rights Reserved.
.PP
This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
Template::Plugin, Image::Info
Zerion Mini Shell 1.0