Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Rebuilding a Tif file after extracting pages and replacing page 1

Posted on 2011-09-20
6
436 Views
Last Modified: 2012-06-22
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:
original_1-0.tif
original_1-1.tif
original_1-2.tif

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:
newpage1.tif
original_1-1.tif
original_1-2.tif

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:
newfile.tif
newfile_1.tif
newfile_2.tif

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?
0
Comment
Question by:nlpalmquist
  • 4
  • 2
6 Comments
 
LVL 38

Accepted Solution

by:
BillDL earned 250 total points
ID: 36572110
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
pause

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:
http://www.experts-exchange.com/Q_27304319.html
"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.
0
 
LVL 38

Expert Comment

by:BillDL
ID: 36572145
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
0
 

Author Closing Comment

by:nlpalmquist
ID: 36580781
Perfect.  Got it all working yesterday.  It will save a very big pile of paper each day.
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 38

Expert Comment

by:BillDL
ID: 36595457
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.
0
 

Author Comment

by:nlpalmquist
ID: 36602100
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.

0
 
LVL 38

Expert Comment

by:BillDL
ID: 36708289
You're most welcome :-)
0

Featured Post

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PaperPort 14.5 Patch 1 update is often not detected or downloaded automatically. This article provides direct download links to solve the problem for retail (non-bundled) versions of the Standard and Professional editions, as well as the Professiona…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The goal of the tutorial is to teach the user how to make his/her own presets while editing so it is easier to edit there photos. Create a preset you like and copy that setting then save it in to your presets folder.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question