Convert multi-page tif to individual tifs

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
bobnic
Posts: 4
Joined: 2015-06-28T04:11:55-07:00
Authentication code: 6789

Convert multi-page tif to individual tifs

Post by bobnic »

I believe the following should work but all it produces is a copy of the original multi-page tif. I have used verbose just in case it helps. The final line of the verbose output would suggest that the resulting file would be the first image in scan0001.tif, but it really is a tif with all 5 images.

Code: Select all

convert -verbose scan0001.tif output%d.tif
scan0001.tif[0] TIFF 1286x1996 1286x1996+0+0 8-bit TrueColor sRGB 39.94MB 0.094u 0:00.097
scan0001.tif[1] TIFF 2046x1376 2046x1376+0+0 8-bit TrueColor sRGB 39.94MB 0.078u 0:00.090
scan0001.tif[2] TIFF 1806x2256 1806x2256+0+0 8-bit TrueColor sRGB 39.94MB 0.078u 0:00.082
scan0001.tif[3] TIFF 1287x2045 1287x2045+0+0 8-bit TrueColor sRGB 39.94MB 0.047u 0:00.059
scan0001.tif[4] TIFF 940x1302 940x1302+0+0 8-bit TrueColor sRGB 39.94MB 0.000u 0:00.017
scan0001.tif=>output.tif[0] TIFF 1286x1996 1286x1996+0+0 8-bit TrueColor sRGB 39.99MB 0.078u 0:00.083
The following does produce the expected individual bmp files.

Code: Select all

convert -verbose scan0001.tif output%d.bmp
scan0001.tif[0] TIFF 1286x1996 1286x1996+0+0 8-bit TrueColor sRGB 39.94MB 0.063u 0:00.060
scan0001.tif[1] TIFF 2046x1376 2046x1376+0+0 8-bit TrueColor sRGB 39.94MB 0.047u 0:00.053
scan0001.tif[2] TIFF 1806x2256 1806x2256+0+0 8-bit TrueColor sRGB 39.94MB 0.047u 0:00.045
scan0001.tif[3] TIFF 1287x2045 1287x2045+0+0 8-bit TrueColor sRGB 39.94MB 0.031u 0:00.033
scan0001.tif[4] TIFF 940x1302 940x1302+0+0 8-bit TrueColor sRGB 39.94MB 0.016u 0:00.024
scan0001.tif=>output-0.bmp[0] TIFF 1286x1996 1286x1996+0+0 8-bit TrueColor sRGB 7.705MB 0.016u 0:00.059
scan0001.tif=>output-1.bmp[1] TIFF 2046x1376 2046x1376+0+0 8-bit TrueColor sRGB 8.449MB 0.031u 0:00.071
scan0001.tif=>output-2.bmp[2] TIFF 1806x2256 1806x2256+0+0 8-bit TrueColor sRGB 12.23MB 0.063u 0:00.104
scan0001.tif=>output-3.bmp[3] TIFF 1287x2045 1287x2045+0+0 8-bit TrueColor sRGB 7.902MB 0.078u 0:00.115
scan0001.tif=>output-4.bmp[4] TIFF 940x1302 940x1302+0+0 8-bit TrueColor sRGB 3.672MB 0.078u 0:00.124
Thanks for any pointers you can provide.

Bob
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Convert multi-page tif to individual tifs

Post by dlemstra »

You are looking for the +adjoin option (http://www.imagemagick.org/script/comma ... php#adjoin). The following command will get you the requested result:

Code: Select all

convert -verbose scan0001.tif +adjoin output%d.tif
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
bobnic
Posts: 4
Joined: 2015-06-28T04:11:55-07:00
Authentication code: 6789

Re: Convert multi-page tif to individual tifs

Post by bobnic »

That works.

Thanks for the very quick reply.

Bob
bobnic
Posts: 4
Joined: 2015-06-28T04:11:55-07:00
Authentication code: 6789

Re: Convert multi-page tif to individual tifs

Post by bobnic »

Just wondering if in fact I have stumbled upon a bug. Reading up on +adjoin:
In summary, ImageMagick tries to write all images to one file, but will save to multiple files, if any of the following conditions exist...

1. the output image's file format does not allow multi-image files,
2. the +adjoin option is given, or
3. a printf() integer format string (eg: "%d") is present in the output filename.
So shouldn't the fact that I included %d in the output file name meant that condition #3 should have "automagically" enabled +adjoin?

Bob
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Convert multi-page tif to individual tifs

Post by dlemstra »

I just tried the command of your first post and I am getting separate files. I was not aware that using %d would also prevent the writer from writing a single file. Which version of ImageMagick are you using and what is your OS?
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
bobnic
Posts: 4
Joined: 2015-06-28T04:11:55-07:00
Authentication code: 6789

Re: Convert multi-page tif to individual tifs

Post by bobnic »

ImageMagick 6.9.1--6 Q16 x64 on Windows 8.1
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Convert multi-page tif to individual tifs

Post by magick »

You need 2 percents in Windows:
  • convert -verbose scan0001.tif output%%d.tif
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert multi-page tif to individual tifs

Post by snibgo »

magick wrote:You need 2 percents in Windows:

convert -verbose scan0001.tif output%%d.tif
That is true, when using BAT script files. From the command line, it is false. If typed at the command line, it would create a file named "output%d.tif".
snibgo's IM pages: im.snibgo.com
Post Reply