How to get the number of images

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
kankan_lee
Posts: 1
Joined: 2015-11-27T03:11:47-07:00
Authentication code: 1151
Contact:

How to get the number of images

Post by kankan_lee »

Some times the ImageMagick convert 1 file to a few images, named by -0, -1, -2....
How can I get the number of the images? I guess there should be some variable I can use directly. :lol:
Thanks!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Contact:

Re: How to get the number of images

Post by fmw42 »

try

Code: Select all

convert image -format "%n\n" info:
that will give you the total number of scenes repeated for each scene. So you have to do some further processing to extract just one of them.

see http://www.imagemagick.org/script/escape.php.

For example:

Code: Select all

convert rose: rose: rose: rose: rose.gif

Code: Select all

convert rose.gif -format "%n\n" info:
4
4
4
4
or in unix you can do

Code: Select all

convert rose.gif -format "%n\n" info: | head -n 1
4
Always best to provide your IM version and platform when asking question on this forum, since IM syntax and scripting differ between unix and windows.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 27 guests