For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > October 2004 > querying image resolutions with perl









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author querying image resolutions with perl
Tom Proctor

2004-10-24, 3:55 pm

Hello,

I’d 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.

Thanks
Tom

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.779 / Virus Database: 526 - Release Date: 10/19/2004


JupiterHost.Net

2004-10-24, 3:55 pm



Tom Proctor wrote:

> Hello,


Hello,

> I’d 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



HTH :)

Lee.M - JupiterHost.Net
Chris Devers

2004-10-24, 8:55 pm

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

> Tom Proctor wrote:
>
>
> 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

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com