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

PERL

    Next

  • 1. Unwanted output using croak with eval
    Consider this program: #!/usr/local/bin/perl -w use strict; use Carp; foo(); print "done\n"; sub foo { eval { bar(); }; print 'In foo(), following eval ... $@', " = $@\n"; } sub bar { croak "croaking in bar()\n"; } Clearly the intent is that foo() wants to handle the case of bar() failing. Yet, this program produces the output: In foo(), following eval ... $@ = croaking in bar() at ./err2 line 17 main::bar() called at ./err2 line 11 eval {...} called at ./err2 line 10 main::foo() called at ./err2 line 6 done Is there a way to suppress the output of croak? Clearly this is a situation where I want to handle the failure myself, and not show this croak output to the enduser.

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

Postby ifiaz » Thu, 20 Nov 2003 00:52:45 GMT

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.

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

Postby Martien Verbruggen » Thu, 20 Nov 2003 14:25:55 GMT

On 18 Nov 2003 07:52:45 -0800,



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).


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.


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.


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.


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 {*filter*}, wet and hungry. Then
Trading Post Australia  | things get worse.
                        | 

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

Postby ifiaz » Fri, 21 Nov 2003 11:22:11 GMT

> Image::Magick will be able to tell you this. You open the image as an
 

Thanks for your suggestions.

I am using Mac OS X, 10.2.8 with perl 5.6.0.

As I don't have Image::Magick in the /System/Library/Perl, I tried to download
it from the CPAN website for PerlMagick-5.57.tar.gz. After the download
completes, I can't follow the instructions from the README.

First hurdle:

local.:~/Desktop/PerlMagick-5.57> perl Makefile.PL
Checking if your kit is complete...
Looks good
Note (probably harmless): No library found for -lMagick
Note (probably harmless): No library found for -llcms
Note (probably harmless): No library found for -lexif
Writing Makefile for Image::Magick

And afterwards I typed 'make' and lots of errors.

 I have no idea how I can have it installed in my system.

If anyone can assist, please...

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

Postby Martien Verbruggen » Fri, 21 Nov 2003 13:05:18 GMT

On 19 Nov 2003 18:22:11 -0800,



You need the ImageMagick library first. The best thing to do is
download the complete IMageMagick distribution from imagemagick.org,
and install the Perl module from that distribution. That way you have
it all in sync.

Maybe you can get some precompiled stuff from whoever provided Perl
for you? Does Apple have their own repository? 

That said, I don't really know whether it is supported on MacOSX. The
documentation seems to suggest that the Unix source should work on
MacOS 10.

Start with unpacking the source, run configure --without-perl (and
whatever other options you need) and make, and install. Change to the
PerlMagick directory, run perl Makfile.PL, make, make test and make
install.

Martien
-- 
                        | 
Martien Verbruggen      | 
Trading Post Australia  | Curiouser and curiouser, said Alice.
                        | 

Similar Threads:

1.How can I create a PDF page with only Images (EPS & TIFF)

Hello Group,

I have lot of EPS and TIFF images that needs to be manually verified.
So I wanted to create a PDF with those images.

I appreciate any help in this regard.

Regards
Dominic

System: Windows 2000
Packages available: Perl 5.8, Image magick and Ghost Script.

2.Multi-page TIFF's --> PDF files

After some wrestling with the PDF::API2 module, I've gotten it to 
faithfully create PDF files from text, which if the first half of my 
project.

Multi-page TIFF's are driving me crazy, however.  The module is only 
picking up one of the pages from the TIFF.  At first I thought it was a 
flaw of the module, but have discovered that many graphics programs have 
this flaw, too.  The latest version of Irfanview, for example, only "sees" 
the first page.

Anyone have any suggestions on this?

Thanks,

Rick

3.tiff images

4.TIFF conversion with Image::Magick

I've been sent some files in TIFF format, with each file
supposedly consisting of several hundred small images
in different "frames". Each file is about 750K or so.

First of all, I've tried to view these images in several
programs, including xloadimage, the GIMP, GQView, and
some others, and there's no indication that they contain
anything more than a single image. 

Second, and Perl-related, I've tried to convert these to PNG
or some other format using Image::Magick, and it is not
working. I used a very simple test script, that works on
standard TIFF files, with the suggested approach of

  $x = $img->Read('image_A.tiff');
  warn $x if $x;

  $x = $img->Write('image_A.png');
  warn $x if $x;

but when I run this, after about 30 seconds of working, I get
a "Killed" response; it doesn't get to the first "warn" stage
at all, let alone give me the nice error messages the docs
promise. I get an identical response using "convert" on the
commandline. I've looked through Martien's book with no luck.

Any suggestions for converting these files? Optimally
I suppose I'd like to get each "frame" saved as a
separate file, but right now I'll settle for finding
out what's going on.

Thanks.

Jesse Sheidlower

5.Tk::TIFF unable to recognize valid TIFF file (follow up)

-format => 'tif'
image file format "tif" is not supported at C:/Perl58/site/lib/Tk/Image.pm
line 21.

no -format option
couldn't recognize data in image file "?" at
C:/Perl58/site/lib/Tk/Image.pm line 21.

----- Original Message ----- 
From: "Tim Harsch" < XXXX@XXXXX.COM >
To: "Steve Lidie" < XXXX@XXXXX.COM >
Cc: "PTK" < XXXX@XXXXX.COM >; "Slaven Rezic" < XXXX@XXXXX.COM >
Sent: Thursday, October 09, 2003 11:31 AM
Subject: Re: Tk::TIFF unable to recognize valid TIFF file


> Hi Steve,
>     Thanks for the suggestions.  I'll give them a try and post results.
>
> This mostly black image, is part of the upper-left corner of 400X
magnified
> slide.  It's not till you work your way more to the center that you see
some
> tissue cores where gene expression experiments are.  Although I haven't
> tried all 190 photos that make up the total image, I have spot checked
ones
> throughout and they have the same issue.
>
> The one thing I should clarify is that this same line of code works for
> other Tiff's coming from the same source that generates them ( a scanning
> microscope that uses a digital camera to take pictures ).  So, I suspect
the
> source of this problem is with the Tk::Tiff module itself.  But I'll keep
> digging for more info.
>
> ----- Original Message ----- 
> From: "Steve Lidie" < XXXX@XXXXX.COM >
> To: "Tim Harsch" < XXXX@XXXXX.COM >
> Cc: "PTK" < XXXX@XXXXX.COM >; "Slaven Rezic" < XXXX@XXXXX.COM >
> Sent: Wednesday, October 08, 2003 5:44 PM
> Subject: Re: Tk::TIFF unable to recognize valid TIFF file
>
>
>
> On Wednesday, October 8, 2003, at 02:38 PM, Tim Harsch wrote:
>
> > Hi all,
> >     I'm having a problem with Tk::Tiff, for some reason I get this
> > error:
> > couldn't recognize data in image file ""?" at
> > C:/Perl58/site/lib/Tk/Image.pm line 21.
> >
> > when trying to read what appears to be a valid tiff.  I've placed the
> > tiff
> > (and the code below) on my FTP server at:
> > ftp://est.llnl.gov/pub/ch19/perltk/bad_images.zip
>
> Well, what the heck does the TIFF show?  All I get on my TIFF-ready Mac
> is mostly black.  If I were led to believe it was a deep-space picture
> in the visible spectrum I'd say, yes, there were two neutron stars and
> a red-dwarf.
>
> >
> > so as not to flood our ancient list server (or your mailboxes :-)
> >
> >     I've verified that the Tif is readable via Image Magick, Adobe
> > Photoshop
> > 2.0 and the Windows OS previewer.  This particular image is primarily
> > black
> > (it is supposed to be, although I have over 190 other example images
> > that
> > have the same problem, not all are just black).  I also, converted the
> > file
> > out using ImageMagick to a Tif copy, which also will not load.  The
> > ImageMagick copy does differ on a binary level from the original, how
> > I'm
> > not sure.  But, the copy is also viewable via Photoshop and Windows.
>
> OK, mostly black, agreed (;
>
> >
> >     The fact that ImageMagick does work with the file and Tk::Tiff
> > does not
> > is a clue I think.  Because, they both use the same libtiff DLL.  Which
> > leads me to believe the problem might be in the Tk::Tiff or Tk::Image
> > module
> > code themselves.
> >
> >     Any ideas?
>
> Lacking a Tk:TIFF module in my Jaguar-moving-to-Panther environment, I
> can only guess, but ...
>
>
> > ##############################################
> > use Tk;
> > use Tk::TIFF;
> >
> > my $mw = Tk::MainWindow->new();
> > my $fname = q/IMAGE002.Tif/;
> > my $p = $mw->Photo(-file => $fname, -format => 'tiff');
> >
>
>
> ... MPTK, p. 428 implies that -format is not be required for TIFF
> files. If so, try removing it.  Perhaps -format in this case should be
> "tif", rather than "tiff".  Obviously this works perfectly well in
> Unix-land, I cannot verify if so in Win32-land.
>
>
> -++**==--++**==--++**==--++**==--++**==--++**==--++**==
> This message was posted through the Stanford campus mailing list
> server.  If you wish to unsubscribe from this mailing list, send the
> message body of "unsubscribe ptk" to  XXXX@XXXXX.COM 

-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to  XXXX@XXXXX.COM 

6. Tk::TIFF unable to recognize valid TIFF file

7. Hyperlink thumbnail image to a larger image on same page

8. I want an perl module for conver large html page file to multi little pages



Return to PERL

 

Who is online

Users browsing this forum: No registered users and 64 guest