Distinguish multi-layer from multi-image

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
rzuris

Distinguish multi-layer from multi-image

Post by rzuris »

What is the best way to distinguish a multi-layer image from an image file containing multiple pages? I used to convert all files with an index of [0] to grab just the first image of multi-page files, for example, to get just the high-res image if the input is a TIFF with a low-res image at index [1]. However, if the input is a multi-layer PSD, specifying an index of [0] means that I miss all the other layers, so I started using -flatten instead. But now, a TIFF with a low-res thumb is (understandably) pixellated when I use -flatten instead of index [0].

Ultimately, I want to use -flatten whenever the input file is multi-layer, but an index of [0] if the input file is multi-page. How can I reliably distinguish the two types, since a TIFF, for example, can be either multi-layer or multi-page?
Post Reply