Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Getting Imager to work with Activeperl

by NewRun (Novice)
on Oct 27, 2009 at 03:13 UTC ( #803367=perlquestion: print w/ replies, xml ) Need Help??
NewRun has asked for the wisdom of the Perl Monks concerning the following question:

I'm writing a program that scans a folder for TIFF files, and then returns the total number of pages in all the TIFF files. I'm using Imager for this, which requires the LibTIFF library. I've gotten this program to work for my unix machine, but I need it to work on my Windows partition.

My Windows partition uses ActivePerl, and the LibTIFF website does have a Windows binary, but I can't figure out where to install the library for ActivePerl to use it.

The LibTIFF website is here:
http://www.remotesensing.org/libtiff/

Comment on Getting Imager to work with Activeperl
Re: Getting Imager to work with Activeperl
by keszler (Priest) on Oct 27, 2009 at 03:41 UTC
    The uwinnipeg.ca repositories have Imager, if you're using Perl 5.6 or 5.8. Add the appropriate one to your PPM:

    Perl 5.6

    Perl 5.8

    The bribes.org repository has Imager for 5.6, 5.8, and 5.10:

    bribes.org

Re: Getting Imager to work with Activeperl
by hangon (Deacon) on Oct 27, 2009 at 06:10 UTC
    If you're only interested in is counting the pages in TIFF files, you don't need Imager. Check out this node for a pure Perl solution. The program counts the pages per TIFF file, so all you would need is a slight modification to totalize the count from all files.
      While I don't understand everything that this code does, it has worked wonderfully. Thank you.

        You're welcome. The code was ripped out of a fax file manager project I wrote a while back. It doesn't make much sense without reading a copy of the TIFF specification, but in a nutshell the code traverses a chain of image directories (basically a linked list) using the while loop. Each image directory contains meta data and pointers for one image, so counting the directories gives you the number of images in the file. Each directory is also parsed for the pointer to the next image directory in the chain. Since TIFF files can be big or little endian, this is detected after the first read so the binary data can be properly unpacked.

        Note that the count too high detection is to prevent the possibility of a corrupt file causing an endless loop. It was arbitrarily set to 100, but a TIFF file can have any number of images, so set it to something sensible for your application.

Re: Getting Imager to work with Activeperl
by syphilis (Canon) on Oct 27, 2009 at 06:13 UTC
    I can't figure out where to install the library for ActivePerl to use it

    Assuming you're using a Microsoft Compiler with ActivePerl, the header file(s) (.h) can go anywhere, but their location needs to be in the INCLUDE environment variable. Add that location if need be:
    set INCLUDE=%INCLUDE%;C:\my_tiff_headers
    The import library (.lib) or static library (.lib) can go anywhere, but its location needs to be in the LIB environment variable. Add that location if need be:
    set LIB=%LIB%;C:\my_tiff_lib
    And if it's a dynamic (not static) library, the dll can go anywhere, but its location needs to be in the PATH environment variable. Add that location if need be:
    set PATH=%PATH%;C:\my_tiff_dll
    That done, the files are all in locations where they can be found.

    If you're using the MinGW compiler, the principle is the same, but the details differ. (The import/static library has a ".a" extension, the CPATH environment variable is used instead of INCLUDE, and the LIBRARY_PATH environment variable is used instead of LIB.)

    Probably easier to just install the ppm package :-)

    Cheers, Rob

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://803367]
Approved by broomduster
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2014-07-28 04:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (186 votes), past polls