Image::Info::TIFF - multi-page tiff images page count

Discussion in 'Perl Misc' started by ifiaz, Nov 18, 2003.

  1. ifiaz

    ifiaz Guest

    How can I get a page count of a multi-page .tif image.

    I browsed in CPAN, but I can't find the TIFF.pm.

    Is there any way to get the page count in perl?

    If not, what is the easiest way to do it using C, etc.?

    Could someone give me the easiest steps to do it as I am quite
    new to perl and programming?

    Just a side question:
    Is tiff the only format that supports multi-page images,
    or are there any other and if any, what are those?

    Thank you.
     
    ifiaz, Nov 18, 2003
    #1
    1. Advertising

  2. On 18 Nov 2003 07:52:45 -0800,
    ifiaz <> wrote:
    > How can I get a page count of a multi-page .tif image.
    >
    > I browsed in CPAN, but I can't find the TIFF.pm.


    Image::TIFF is part of the Image-Info package. If you install the
    package, you'll have it. You can't, or at least shouldn't, ever try to
    get separate files out of a distribution.

    However, I don't think that that supports multi-image formats (I might
    be wrong. I haven't actually tried it, just browsed the documentation).

    > Is there any way to get the page count in perl?


    Image::Magick will be able to tell you this. You open the image as an
    IM object, and then you just count the number of elements in it.

    > If not, what is the easiest way to do it using C, etc.?


    Probably also with the ImageMagick libary, or maybe directly with the
    freely available tiff library (www.libtiff.org), possibly already on
    your system, depending on your OS and vendor.

    > Could someone give me the easiest steps to do it as I am quite
    > new to perl and programming?


    Lessee..

    #!/opt/perl/bin/perl
    use strict;
    use warnings;
    use Image::Magick;

    # Create a multi-image TIFF document
    {
    my $im = Image::Magick->new();

    # Read some JPG images
    my $rc = $im->Read(glob("/tmp/P*.JPG"));
    die $rc if $rc;

    # Save the whole thing as a TIFF file
    $rc = $im->Write("foo.tiff");
    die $rc if $rc;
    }

    # Read the TIFF document
    {
    my $im = Image::Magick->new();
    my $rc = $im->Read("foo.tiff");
    die $rc if $rc;

    # An Image::Magick object is just a reference to an array, with
    # each element an image.
    my $n_images = @$im;
    print "I've got $n_images images\n";
    }

    Note that Image::Magick generally relies on an external tiff library
    to write and read images.

    > Just a side question:
    > Is tiff the only format that supports multi-page images,
    > or are there any other and if any, what are those?


    Photoshop, MNG, ImageMagick's MIFF format, GIMP XCF, GIF, PostScript,
    PDF, FAX, FITS (I believe), The various Flash and Macromedia formats,
    MPEG, and many others. Not all of these are pure image formats or even
    mainly image formats, and what a "frame/page/image/layer" in each of
    these means is often application dependent. In fact, what multiple
    images in a single TIFF document mean is dependent on the encoding and
    context.

    Martien
    --
    |
    Martien Verbruggen | We are born naked, wet and hungry. Then
    Trading Post Australia | things get worse.
    |
     
    Martien Verbruggen, Nov 19, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chuck Taylor
    Replies:
    1
    Views:
    8,299
    Chuck Taylor
    Sep 4, 2003
  2. Kuldeep

    Multi Page Tiff

    Kuldeep, Sep 7, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    423
    Kuldeep
    Sep 7, 2006
  3. Replies:
    0
    Views:
    1,609
  4. Rick Nakroshis

    Multi-page TIFF's --> PDF files

    Rick Nakroshis, Nov 9, 2003, in forum: Perl Misc
    Replies:
    1
    Views:
    110
    Ben Morrow
    Nov 9, 2003
Loading...

Share This Page