possible bug with string formats "%n" and "%[scenes]"

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

possible bug with string formats "%n" and "%[scenes]"

Post by fmw42 »

IM 6.6.0-9 Q16 Mac OSX tiger

When trying to get the number of scenes from a pdf or gif, the number of scenes repeats once for each scene. For example:

convert rose: rose: rose: rose3.gif
convert rose.gif -format "%n" info:
3
3
3


I would expect only one 3 to be returned.

Same with


convert rose: rose: rose: rose3.pdf
convert rose.pdf -format "%[scenes]" info:
3
3
3

Let me know if this is the correct behavior.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug with string formats "%n" and "%[scenes]"

Post by magick »

-format is applied to each image in a sequence. For each image in the sequence, they all have the same sequence length of 3. Its a bit redundant but given that -format is an image operator rather than an image sequence operator the behavior is expected. To fix, we would need to create a new option that applies to an image sequence rather than one an image by image basis.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug with string formats "%n" and "%[scenes]"

Post by fmw42 »

magick wrote:-format is applied to each image in a sequence. For each image in the sequence, they all have the same sequence length of 3. Its a bit redundant but given that -format is an image operator rather than an image sequence operator the behavior is expected. To fix, we would need to create a new option that applies to an image sequence rather than one an image by image basis.

Thanks for the explanation. Here is a work around:

echo `convert rose.gif -format "%n" info:` | cut -d\ -f1
3

(note there needs to be two spaces between the \ and -f1)


And this just gets the last scene number, so you can add 1 to it to get the number of scenes.

convert rose.gif[-1] -format "%s" info:
2
Post Reply