On Sun, 24 Oct 2004, JupiterHost.Net wrote:

Tom Proctor wrote:

Id like to write a Perl script that returns the X and Y resolution
of a given image file.  Does anyone know of a module that might
support this function?  Ideally it would support a wide variety of
image file formats.

Try:

http://search.cpan.org/

Imager
Image::Magick
GD

Or, more to the point, Image::Size:

     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 scalar

A brief search on CPAN or Google should have had this near the top of the list, had you tried to search before asking the list. If you're doing a lot of graphics work, the book _Perl Graphics Programming_ is good & worth taking a look at: <http://www.oreilly.com/catalog/perlgp/>


-- Chris Devers


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to