Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

CPAN "Imager" Module Question

by ack (Deacon)
on Nov 08, 2010 at 06:01 UTC ( [id://870036]=perlquestion: print w/replies, xml ) Need Help??

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

I am trying to use the CPAN "Imager" module to do some fairly simple imager processing (mostly edge detection) using grey-scale JPEG and GIF files as inputs.

The source images are color, but since I only need to detect edges, I have converted the color images to 8-bit grey scale (JPEG and GIF depending upon what the source file format was) and saved then as grey scale for input to my Perl script.

I have been developing the script on my PC at work (an Intel Dual Core with about 2MB of RAM running Windows XP Pro). I used the constructs:

#!/usr/bin/perl use strict; use warnings; $| = 1; # set print buffering to not buffer use Imager; my @read_types = Imager->read_types; my @write_types = Imager->write_types; print "Read Types:\n"; print " ",join(", ",@read_types),"\n"; print "Write Types:\n"; print " ",join(", ",@write_types),"\n"; exit(0);

It showed that, as I needed, it supports JPEG and GIF formats among others.

I decided to bring my work home with me to continue the development over the weekend.

The script kept failing and it took me a while to figure out why.

Then I tried the above listed script and found that the output says Imager on my home laptop only supports the following:

Read Types: sgi, bmp, ico, pnm, tga, raw Write Types: sgi, bmp, ico, pnm, tga, raw

I am confused. This says that on my laptop (an Intel(R) Pentium(R) M 900 MHz with 500 MB of 593 MHz RAM runing Windows XP Pro) I don't have support for JPEG or GIF! These are two of the most popular image formats.

In both cases (i.e., on both computers) Imager was installed from the ActiveState web site using the Perl Package Manager (PPM) and both are the same version of Imager (version 0.78).

I have looked at the CPAN documentation for Imager and its sub-topic documentation (e.g., the "Files" and "ImageTypes") but all it says is that the file types supported are determined by what options Imager was compiled with; but since on both computers the modules are pre-complied and loaded from ActiveState using PPM then I wouldn't think that is the source of the discrepancy.

I keep thinking this should be obvious, but it isn't to me. So, I have a three questions.

First, this doesn't make sense to me, so what am I missing? (it's got to be me).

Then, on the outside chance that it *isn't* so straightforward:

Second, why do two different Intel processor platforms (both running Windows XP Pro) support different Image file formats?

Third, why would *any* platform, irrespective of the processor, *not* support JPEG and/or GIF?

As an aside, I have converted the images to BMP format (which both platforms support) and am getting along. But the above is still troubling me.

ack Albuquerque, NM

Replies are listed 'Best First'.
Re: CPAN "Imager" Module Question
by Anonymous Monk on Nov 08, 2010 at 07:10 UTC
    I'd say that at the job, Imager-File-JPEG and Imager-File-GIF have been installed, and at home you haven't. Easily remedied with a CPAN visit.
    M.

      Interesting and I'll look into that. Thanks.

      One thing is still nagging at me. All of the Perl stuff (CPAN, Perl, etc.) was entirely created by me (rather than others such a Sys Admin) on both machines as I have Administrator priviledges on both.

      I did not, to the best of my knowledge on one machine versus the other. And, of course my Sys Engr part of me says..."Ah Hah! You SAY you didn't do anything differently so guarenteed you DID and just don'e recognize it!"

      Most noteably, I know I never did any compiling of source codes on either machine (of that I'm sure). So I honestly don't know how I could possibly have ended up with different modules (compiled or otherwise) on either machine.

      But both your respose and jdrago999's response suggest otherwise and the logic of both reponses is reasoned and sensible. So I'll look into it.

      But if it turns out to be as both or either of you suggests, then "the plot thickens" and it becomes "curiousor and curiousor" to badly paraphrase two good quotes.

      Thank you both.

      ack Albuquerque, NM
Re: CPAN "Imager" Module Question
by jdrago999 (Pilgrim) on Nov 08, 2010 at 19:14 UTC

    You have to install libjpeg and/or libpng on your machine. You may also have to compile the Imager module via CPAN instead of using the ActiveState version.

    It's been a while since I did any Perl on Windows, but that's how it is in Linux and I use Imager all the time.

      jdrago999, thanks so much for your response. Since both yours and Anonymous Monk's (above) are similar, I posted a reply to Anonymous Monk's for yours there, too. I hope that isn't offensive as I really appreciate the good thought that you each provided.

      Again, thanks so much for your thoughtful response and I am investigating your idea.

      ack Albuquerque, NM
Re: CPAN "Imager" Module Question
by tonyc (Pilgrim) on Nov 22, 2010 at 00:21 UTC

    Do you happen to be using strawberry perl on your work machine?

    Strawberry comes with Imager, with most of the file formats enabled, which could explain why it works there.

    Installing the ActiveState PPM over that wouldn't remove Imager::File::JPEG, so it would stay available.

    If your home laptop is running ActiveState perl it won't have an already installed Imager::File::JPEG to fallback to when you install the ActiveState PPM.

    Strawberry also includes the headers and libraries to installed Imager from source with the most useful file formats.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://870036]
Approved by biohisham
Front-paged by biohisham
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-03-19 03:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found