ImageMagick - Splitting Multi-Page Tiff to Single Page, but first Image name suffix is not Zero
Aug 12, 2012
Suresh Vasudev
1 minute read

We have a requirement to split multi-page Tiff to single pages and we are using ImageMagick “convert” function.

Example:

Convert abc.tif abc_%d.tif

if abc.tif has 5 pages then on successful execution of the above command it will create five single pages with images names as abc_0.tif,abc_1.tif,abc_2.tif,abc_3.tif and abc_4.tif

This function was working fine and once in a while for certain images it will create images starting with suffix 1 (ONE) instead of 0 (Zero)

However our application expects all such split images to start with Suffix Zero.

The ImageMagick documentation mention about a switch -scene which sets the scene number of an image or the first image in an image sequence.

The above code was then modified and applied against such images to ensure that it starts with suffix ZERO

Convert -scene 0 abc.tif abc_%d.tif

If we provide a different number, then the suffix will start with that number. For example if we mention -scene 100 then the first image name will abc_100.tif.