Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Using the Imager package

by LloydRice (Beadle)
on Dec 19, 2011 at 23:26 UTC ( [id://944316]=perlquestion: print w/replies, xml ) Need Help??

LloydRice has asked for the wisdom of the Perl Monks concerning the following question:

Running ActiveState Perl v5.12.4 with Win7Pro on a Gateway SX-2841 (64-bit). I am trying to understand the Imager package. I started by installing: >ppm install Imager This seems to have worked OK. I have printed and read all of the .doc files. Let me start with the question, "How do I read a PNG iamge?" I started with some code from the tutorial::
use Imager; my $image_source = $ARGV[0]; my $image = Imager->new; $image->read(file=>$image_source) or die "Cannot load $image: ", $image->errstr;
then, when I try to read the PNG file, I get
>perl d2020.png Cannot load Imager=HASH(0x10d970): format 'png' not supported - formats bmp, ico, pnm, raw, sgi, tga available for reading - Can't locate Imager/File/ at C:\c\Perl\graphics\ line +4.
OK. So maybe I do not have the PNG code?
use Imager; printf "%s\n", join " ", Imager->read_types; printf " %s\n", join " ", keys %Imager::formats;
This produces two lists:
sgi bmp ico pnm tga raw bmp pnm tga ifs raw w32
Somewhere, I read a comment that there's a bit of a trick to loading the code for different formats. I said to ask for help. I'm doing that now....

Replies are listed 'Best First'.
Re: Using the Imager package
by tonyc (Friar) on Dec 20, 2011 at 06:55 UTC

    Imager doesn't include the low level libraries for reading formats like PNG - just an interface to them.

    The simplest way to work with Imager on Win32 is strawberry perl, which includes Imager and the libraries that Imager needs.

    If you really want to use ActiveState perl, you could grab the libraries and headers from the strawberry perl zip files.

      OK, Tonye. I see. I will look into Strawberry Perl, but I am cautious about problems which might develop by mixing versions. In the meantime, I have gone ahead reading a BMP version of the same image. That work is underway. Many thanks for your reply.
        Tony, sorry about misspelling your email name. I now realize that you are none other than Tony Cook, the one and only whose name appears throughout the Imager documentation.
Re: Using the Imager package
by keszler (Priest) on Dec 19, 2011 at 23:54 UTC

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://944316]
Approved by GrandFather
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-06-19 20:17 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.