- مرات التنزيل: 172
- متطلبات التشغيل:
- الاصدار : 3.231
- اضيف في: 0000-00-00 00:00:00
- اخر تحديث: 29/05/2012
- الموقع علي الانترنت:
Image::Size is a Perl module that can read the dimensions of an image in several popular formats.SYNOPSIS use Image::Size; # Get the size of globe.gif ($globe_x, $globe_y) = imgsize("globe.gif"); # Assume X=60 and Y=40 for remaining examples use Image::Size 'html_imgsize'; # Get the size as 'width="X" height="Y"' for HTML generation $size = html_imgsize("globe.gif"); # $size == 'width="60" height="40"' use Image::Size 'attr_imgsize'; # Get the size as a list passable to routines in CGI.pm @attrs = attr_imgsize("globe.gif"); # @attrs == ('-width', 60, '-height', 40) use Image::Size; # Get the size of an in-memory buffer ($buf_x, $buf_y) = imgsize($buf); # Assuming that $buf was the data, imgsize() needed a reference to a scalarThe Image::Size library is based upon the wwwis script written by Alex Knowles ([email protected]), a tool to examine HTML and add 'width' and 'height' parameters to image tags. The sizes are cached internally based on file name, so multiple calls on the same file name (such as images used in bulleted lists, for example) do not result in repeated computations.Image::Size provides three interfaces for possible import:imgsize(stream)Returns a three-item list of the X and Y dimensions (width and height, in that order) and image type of stream. Errors are noted by undefined (undef) values for the first two elements, and an error string in the third. The third element can be (and usually is) ignored, but is useful when sizing data whose type is unknown.html_imgsize(stream)Returns the width and height (X and Y) of stream pre-formatted as a single string 'width="X" height="Y"' suitable for addition into generated HTML IMG tags. If the underlying call to imgsize fails, undef is returned. The format returned is dually suited to both HTML and XHTML.attr_imgsize(stream)Returns the width and height of stream as part of a 4-element list useful for routines that use hash tables for the manipulation of named parameters, such as the Tk or CGI libraries. A typical return value looks like ("-width", X, "-height", Y). If the underlying call to imgsize fails, undef is returned.By default, only imgsize() is exported. Any one or combination of the three may be explicitly imported, or all three may be with the tag :all.Input TypesThe sort of data passed as stream can be one of three forms:stringIf an ordinary scalar (string) is passed, it is assumed to be a file name (either absolute or relative to the current working directory of the process) and is searched for and opened (if found) as the source of data. Possible error messages (see DIAGNOSTICS below) may include file-access problems.scalar referenceIf the passed-in stream is a scalar reference, it is interpreted as pointing to an in-memory buffer containing the image data. # Assume that &read_data gets data somewhere (WWW, etc.) $img = &read_data; ($x, $y, $id) = imgsize($img); # $x and $y are dimensions, $id is the type of the imageOpen file handleThe third option is to pass in an open filehandle (such as an object of the IO::File class, for example) that has already been associated with the target image file. The file pointer will necessarily move, but will be restored to its original position before subroutine end. # $fh was passed in, is IO::File reference: ($x, $y, $id) = imgsize($fh); # Same as calling with filename, but more abstract.Product's homepage Requirements:
What's New in This Release: [ read full changelog ]
· Compress::Zlib is now optional.
· The distribution was refactored.
· The cache was made visible outside the lexical scope of the module to make it possible to use with IPC.