Partially-splitting a multipage tif file

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
shumcal
Posts: 2
Joined: 2014-08-11T19:48:32-07:00
Authentication code: 6789

Partially-splitting a multipage tif file

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Partially-splitting a multipage tif file

Post 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
shumcal
Posts: 2
Joined: 2014-08-11T19:48:32-07:00
Authentication code: 6789

Re: Partially-splitting a multipage tif file

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Partially-splitting a multipage tif file

Post 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%
snibgo's IM pages: im.snibgo.com
Post Reply