Page 1 of 1

How to get the number of pages from a TIF?

Posted: 2015-09-18T05:26:00-07:00
by Antoine4851
Hi,

I want to get the number of pages from a TIF using command line.
I know there's the component identify.exe but I don't find the parameters to apply.
I need to get the number of pages into a variable.

Thanks for any help

Antoine

Re: How to get the number of pages from a TIF?

Posted: 2015-09-18T05:48:26-07:00
by snibgo
One method:

Code: Select all

identify -ping -format %n\n multi.tiff
This will output (n) lines, one per image. Each line will contain the number (n). Grab any of those into a variable. See http://www.imagemagick.org/script/escape.php

There may be a single-line solution, but I can't find one.

Re: How to get the number of pages from a TIF?

Posted: 2015-09-18T07:47:39-07:00
by Antoine4851
I tried this method but I don't know how to put the result in a variable...

Re: How to get the number of pages from a TIF?

Posted: 2015-09-18T07:58:49-07:00
by snibgo
ImageMagick won't put it into a variable. Your script needs to do that.

Re: How to get the number of pages from a TIF?

Posted: 2015-09-18T09:57:43-07:00
by fmw42
What platform and what version of IM. If Unix, then

Code: Select all

number=$(identify -ping -format "%n\n" multi.tiff | tail -n -1)