Solved

Rebuilding a Tif file after extracting pages and replacing page 1

Posted on 2011-09-20
6
421 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Exchange and Third Party application. 8 59
Magic Software info 18 103
Path of Workbook 3 45
How to modify text in a png image 10 57
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this Micro Tutorial viewers will learn the basic shortcuts and functions in InDesign.
The goal of the tutorial is to teach the user how to use import presets downloaded from the internet into Adobe Lightroom. Once you downloaded the presets go into the preset folder and press import then import your preset and your set it to go.

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now