Number of pages of tiff in version 6.9.1

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
mundi
Posts: 5
Joined: 2015-05-08T01:25:18-07:00
Authentication code: 6789

Number of pages of tiff in version 6.9.1

Post by mundi »

Hello,

Using ImageMagick 6.9.0 I got the number the pages of a multipaged tiff using the command

Code: Select all

identify -format %n [name of tiff file]
this returned me for a specific tiff "602PS". Now after upgrading to version 6.9.1 the same command results me
"602602602602602602602...(and so on)PS".

Why is this returning the number of pages multiple times? Am I missing something or is there a bug in the newest version?

Thanks
246246
Posts: 190
Joined: 2015-07-06T07:38:22-07:00
Authentication code: 1151

Re: Number of pages of tiff in version 6.9.1

Post by 246246 »

I don't know when it changes, but even if I use older version, only "%n" was special - "%n\n" or even "%n " produced multiple output. Probably developer has changed it for keeping consistency.

[EDIT]
I checked 6.7.6-3 on Cygwin, 6.5.4-7 on CentOS.

And for tiff, check this also. viewtopic.php?f=1&t=28045
Last edited by 246246 on 2015-07-28T08:27:57-07:00, edited 1 time in total.
mundi
Posts: 5
Joined: 2015-05-08T01:25:18-07:00
Authentication code: 6789

Re: Number of pages of tiff in version 6.9.1

Post by mundi »

For me in the 6.9.0 version it always produced the output only once, nevertheless if I use "%n", "%n\n" or "%n ".

It seems that for the latest version 6.9.1 it produces its output once per page...
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Number of pages of tiff in version 6.9.1

Post by fmw42 »

just use identify on the first page

Code: Select all

identify -format "%n\n" yourimage.tiff[0]
246246
Posts: 190
Joined: 2015-07-06T07:38:22-07:00
Authentication code: 1151

Re: Number of pages of tiff in version 6.9.1

Post by 246246 »

fmw42 wrote:just use identify on the first page

Code: Select all

identify -format "%n\n" yourimage.tiff[0]
It returns always 1 (in 6.9.1-10 on Windows)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Number of pages of tiff in version 6.9.1

Post by fmw42 »

Yes, you are right. In unix one could do:

Code: Select all

identify -format "%n\n" image.tif | tail -n 1
to get just the last value. Sorry I do not know Windows equivalent.

You could request a change in the Developers forum so that it only prints out the number of images in the current sequence once.
246246
Posts: 190
Joined: 2015-07-06T07:38:22-07:00
Authentication code: 1151

Re: Number of pages of tiff in version 6.9.1

Post by 246246 »

In some environment or older version, I have experienced identify generate extra newline at the end. So "head -1" is safer.
In Windows CMD (without extra install), it becomes tricky,

> identify image.tiff | findstr /v /r "^$" | find /c /v ""

(findstr is for sure to remove an empty line.)

Its unix equivalent is something like

% identify image.tiff | grep -v "^$" | wc -l
246246
Posts: 190
Joined: 2015-07-06T07:38:22-07:00
Authentication code: 1151

Re: Number of pages of tiff in version 6.9.1

Post by 246246 »

mundi wrote:For me in the 6.9.0 version it always produced the output only once, nevertheless if I use "%n", "%n\n" or "%n ".

It seems that for the latest version 6.9.1 it produces its output once per page...
Just curious what is your OS and exact version of your ImageMagick?
(I tested with 6.9.0-10 and it behaves the same as current 6.9.1-10.)

And what output is generated from your 6.9.0 for the following command?

Code: Select all

identify -format "%n %g\n" multipage.tiff
If it generate only 1 line for multipage tiff, it was bug on that version. Current behaviour would be sane, even though it is inconvenient.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Number of pages of tiff in version 6.9.1

Post by fmw42 »

IM 6.9.1.10 Q16 Mac OSX SnowLeopard


3 70x46+0+0
3 70x46+0+0
3 70x46+0+0
mundi
Posts: 5
Joined: 2015-05-08T01:25:18-07:00
Authentication code: 6789

Re: Number of pages of tiff in version 6.9.1

Post by mundi »

Thanks for the hints.

What I did now is that I wrote a small powershell script:

Code: Select all

$pages = identify -format "%n " [name of tiff file]
echo $pages.subString(0, $pages.indexOf(" "))
This gives me the number of pages.

Thanks for your help
Post Reply