Page 1 of 1

Partially-splitting a multipage tif file

Posted: 2014-08-11T19:54:49-07:00
by shumcal
Hi

I'm running ImageMagick 6.8.9-6 Q16 on Windows from command line.

I have a multi-page tif file, which I'm trying to split every two (or another number) of pages into smaller multipage tif files. Is there a way I can do this, ideally in a single command?

Cheers

Re: Partially-splitting a multipage tif file

Posted: 2014-08-11T20:06:58-07:00
by fmw42
You can select frames/pages/layers using the image.tif[1,3,5,7,9 ....] type syntax for say every other frame, where you have to list every other frame (the ... is not part of the syntax). Unfortunately, IM does not have an automatic skip option in this type of sequence, for which I think is a lacking feature and would be useful to have.

Code: Select all

convert image.tiff[0,2,4,6,8,10,12,14,16] result.tif
Frame numbers start with 0.

So what you need to do is write a loop to compute the frame numbers you want and store in a string. Then use that inside [ ... ].

See the section on selecting frame at http://www.imagemagick.org/script/comma ... hp#anatomy

Re: Partially-splitting a multipage tif file

Posted: 2014-08-11T23:24:06-07:00
by shumcal
Thanks, it looks like I might be able to do what I need with a combination of splitting, merging, and a third-party script.

Re: Partially-splitting a multipage tif file

Posted: 2014-08-12T00:10:43-07:00
by snibgo
A Windows BAT script to generate the even numbers:

Code: Select all

setlocal enabledelayedexpansion

set evens=

for /L %%n in (0,2,20) do set evens=!evens!,%%n

rem Remove leading comma.

set evens=%evens:~1%

echo %evens%