0

I have a tiff file with several hundred pages in it. My goal is to break it into many files each containing two pages. i.e. every two pages save a new file. It is basically a stack of single sheet documents scanned front and back.

I'm working on a C# Forms (visual studio 2008) application to automate the process.

My initial thought is to use Graphicsmagick to split every page into a seperate file then step through the files to join them back to geather again two pages at a time.

I have the split process working by calling a command like this.

gm convert largeinputfile.tif +adjoin singlepageoutput%d.tif

When I try and join just two of the pages back togeather again with a command like this

gm convert -page A4 -append singlepageoutput0.tif singlepageoutput1.tif New2pageImage.tif

This creates one long document containing both pages but no page break. I have tried seveveral things with the -page option but I'm just guessing and it's not having much effect.

I'm very close to a working solution but stuck on the last bit. Any ideas?

Thanks in advance David

Andrea
  • 11,801
  • 17
  • 65
  • 72
David P
  • 411
  • 7
  • 21
  • I hate answering my own questions but I was barking up the wrong tree. :) The answer is gm convert -adjoin singlePage0.tif singlePage1.tif newoutput.tif – David P Mar 28 '13 at 05:13

1 Answers1

0

Thought I would answer this as I had a similar problem and this was the first SO question I came across.

This will take the first two pages and create a new multi-page tiff file.

gm convert -page A4 page0.tif page1.tif -adjoin output.tif

Then you take the file you have created and add a new page to it.

gm convert output.tif page2.tif -adjoin output.tif
gm convert output.tif page3.tif -adjoin output.tif
.... and so on ....

This will also have the added benefit of not eating through CPU and RAM as graphics magick will try to do the whole thing in RAM and a 10MB 500 page tiff will take about 24GB of RAM if done in one go.

onmylemon
  • 724
  • 8
  • 25