Search code examples
graphicsmagick

Check how many pages are included in a multi-page image file with GraphicsMagick


Is there a way to determine in advance how many pages are included in a multi page tif image with GraphicsMagick ? I know I can select the first page in this way : image.tif[0], and probably iterating the array until the command fail will return the last image, but I don't think this is the best approach.


Solution

  • You can get a numbered list of the pages with

    gm identify image.tif
    

    and look at the last line, or count the lines. The images are numbered 0 thru N -1.