• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 479
  • Last Modified:

Rebuilding a Tif file after extracting pages and replacing page 1

BillDL - posted excellent suggestion to use nconvert to split the pages apart and replace page 1.  It did exactly what I needed - except I am unable to recombine the pages once I get them together.

I got the nconvert as suggested.  

nconvert -xall original.tif

it made 3 files - one for each page - I assume the pattern would continue for larger files:

I made a file called: list.txt and listed the pages I want in the new document - seemed the way to do this.  

list.txt contains:

Then I ran the nconvert -multi command like this:

nconvert -multi -l list.txt -o newfile.tif

What it did here was make three new files:

These would represent the three pages I want in a new file.  I can not figure out how to get them back together with this software.  Am I missing something?
  • 4
  • 2
1 Solution
Hi again nlpalmquist

I assume that you have already created a usage file as a reference?

nconvert -help>nconvert_usage.txt

Try adding the -out output file format to the end of the command so that nConvert knows that it is not converting each source file, but packing them into one *.TIF file:

nconvert -multi -l list.txt -o newfile.tif -out tiff -v

Note: you must use TIFF as the name of the file output format, not TIF.
The -v switch will show verbose output, so you can either see this on screen or redirect all screen output to a log file like this:

@echo off
echo creating newfile.tif from files in list.txt ...
nconvert -multi -l list.txt -o newfile.tif -out tiff -v > logfile.txt 2>&1
echo Finished

That works for me using a bunch of JPGs as the source, so it should work using the separate TIF files.  All you need to do now is test the results of the various TIFF compression values using the -c switch. Try a value of 2 which is LZW compression and see if it matches the original file size of the multi-TIFF before you replaced page 1:

nconvert -multi -l list.txt -o newfile.tif -out tiff -c 2 -v > logfile.txt 2>&1

Original question relating to this was:
"I have to replace page 1 of the tiff with a different page, and re save the tiff.  I need to be able to specify the size of the tiff properly to keep the file as small as possible for storage.  This amounts to changing the coversheet of the tiff.  I have to generate a new coversheet and convert it to the appropriate format to be inserted into the tiff.  I have hundreds of these to do each day and it is an ongoing functions so it needs to be automated."

I will try to get time to create a batch file to automate this.
Once happy that the program creates your multi-page TIF file from the source images, you can add the uppercase -D switch to delete the files that were used as the source, ie. the ones in the list file:

nconvert -multi -l list.txt -o newfile.tif -out tiff -c 2 -D -v > logfile.txt 2>&1
nlpalmquistAuthor Commented:
Perfect.  Got it all working yesterday.  It will save a very big pile of paper each day.
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Thank you nlpalmquist, I'm pleased that you have saved yourself a pile of work.  Out of curiosity I created a little batch file that allows you to drag and drop a Multi-TIFF file onto it and (almost) automates the process of rebuilding it with the new front page image which it prompts you to name and expects to be in the same folder.  Most of it is just error checking and the commands are just as you will be using though.  I would imagine that you will have created some kind of bath file yourself by now though.
nlpalmquistAuthor Commented:
I love your willingness to try it.  That was above and beyond.

I have to run through a few hundred in each process and it needed to have additional rules. I have to create a new first page from a list of orders- PCF converted to TIF,  I have to fetch the old Tiff,  I have to bust the old tiff apart, make a list of the pages in the right order - this worked the best for reassembly.  Some old tiffs had more than 100 pages and the naming that nconvert used made it easy to load them into a list in order, replacing page 1 with the new name.

Then reassemble for the final tiff.

I do all this from our software where I have better tools for doing things.  But your solution got it working. I sent out questions in a few directions - since I could not find the right tool and was almost at the point of hiring a solution - I thought there must be something someone already wrote but could not find it.  Sometimes that is the hardest part when you moving into areas of less familiarity.
Again my thanks.

You're most welcome :-)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now