Replace page 1 of a tiff with a new page - Command line - Windows

Posted on 2011-09-12
Last Modified: 2012-08-13
I need to do this from a command line so it can be automated.  It runs on a WindowsXP or newer OS.

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.
Can anyone suggest a software package that I might look at to solve this problem?  We have been trying to print the cover page then the tiff and then rescanning the stuff, but this is just killing trees of paper and is unnecessary if we can figure out how to do it without the paper step.

Question by:nlpalmquist
  • 4
  • 2

Expert Comment

ID: 36526292
I have a client that uses this and they like it.  The main thing they do is batch scan with the bar code in the middle so it knows where to make a new file automatically.  There are a few other things it does automatically also like sizing, straightening, and ORC to an index if you match it up to their archiver program.  You can also auto name things if you want to input that data into the bar codes too.

As for your actual purpose, I would just use the tiff editor to add the page to the front and call it a day.  While not quite automated, it will save you time and paper from having to print it all out just to scan it back.  But if you did print it all out, you could put it into a single big stack of paper and have it scan the pile as one job, but saved as many files.

Author Comment

ID: 36529276
We are trying to change a document that was already scanned, some time ago and is stored on our system, We need to remove page 1 and replace it with a different page 1.

There are too many to manually open each document and manipulate it.  It needs to be something we can do from a command.  

We really want to avoid having to hit paper, it seems very wasteful to print out the stuff just to scan it again.

We could convert to another format if it would be better to work in PCL or something else like that.
LVL 38

Accepted Solution

BillDL earned 500 total points
ID: 36554570
I assume from what you say that the page you need to insert in place of the existing page 1 is already a *.TIF file?
My question isn't as dumb as it may at first seem, because it is quite feasible that other image file types could have been used as the source and converted during the encoding of a new *.TIF file.

I'll be honest here and admit that I haven't produced many multi-page TIF images myself, and therefore have not tested many programs capable of doing this, but my first thoughts are that you could use the IrfanView image editor and viewer from the command line.

It is only free for non-commercial use, but needs to be registered and a "sum" paid to use it for businesses:

It reads from and writes to TIF files without a plugin, although there are plugins for other formats available:

The program is self-contained and doesn't write anything to the registry (other than the usual MRU data) UNLESS you choose to associate any of the file extensions in the user preferences and create a Right-Click > Browse with IrfanView menu option for folders.  It creates and updates its own *.INI settings file in the same folder as the EXE, and you will there also find a file named "i_options.txt" in which you will see the extensive list of available command line options and examples of use.

The two relevant ones to your question are the switch that extracts images from a multi-TIF file, and then the one that creates a multi-TIF file from named source images.

i_view32.exe /extract=(folder,ext) - extract all pages from a multipage file
i_view32.exe  /multitif=(tif,files) - create multipage TIF from input files

The idea I have (with a batch file) is to:
1. Extract all pages from a TIF file to their own sub-folder as image files with specified extensions
2. Copy your facing page to that folder so that it comes alphabetically first
3. Using a DIR listing that puts the files in correct page order, create a new Multi-TIF
4. Remove sub-folder and extracted images
4. Repeat for all other TIF files in the folder.

I know this idea is clunky and requires "unpacking" and then "reassembly", but there is no option with IrfanView to actually overwrite an image IN-PLACE within a multi-TIF file, only to APPEND a new image to the existing ones:
i_view32.exe /append=tiffile - append image as (TIF) page to "tiffile"

There is a    /tifc    switch in which you can specify TIF compression but I am not sure if it can be used at the time of creating a new TIF file or only on an existing TIF:  None, LZW, Packbits, Fax3, Fax4, Huffman, JPG, ZIP

I'm sure that IrfanView would be usable with a batch file, but I will need to post back with one a bit later as I have a few things to do.

Is this idea one that you can use in your current environment?
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

LVL 38

Expert Comment

ID: 36554575
I will also look at ImageMagick (, but it has a HUGE number of options and I will have to do a bit of searching.  maybe another expert will post about this program (or actually a group of separate EXEs) before I return to finish my IrfanView suggestion.
LVL 38

Expert Comment

ID: 36554619
Yes, I'm just going ;-)  Thought I would look up some links first:

Split Multi-TIF to separate images using Visual Basic and two FreeImage" functions:
I don't know enough about Visual basic, but I'm sure many experts here would be able to work something out if you can find a "partner" article that tells you how to PREpend an image to an existing one, or split, add an image, then combine.

Prepending a page to a multi-TIF using something named "ARIE-L Document Transmission System":
It's probably overkill and maybe very expensive.  I haven't read about it yet:

Axommsoft Tiff Split Merge:
Not sure if there are command line options.

Author Closing Comment

ID: 36560133
It will take some time to experiment but this expert really gave me a great place to start and I think this will do the trick.  Thank you for the clear notes and links to more information.
LVL 38

Expert Comment

ID: 36563354
Thank you nlpalmquist

Just to update a couple of things I posted.  I have looked through the ImageMagick commands and various related discussion sites, and I do not think from what I have read that this program is able to prepend a new page to a Multi-TIF file.

Another program that runs ONLY from the command line is a little one named "nConvert" and is the partner program for the free XnView:

If anything, there are more options for image manipulation in nConvert, but for your purposes the relevant options are:
-xall     : Extract all images
-multi  : Create a multi-page (TIFF/DCX/LDF)

I was going to try and create an "IrfanView" or "nConvert" batch file that you could have tried with a few of your TIF files in a test folder, but I haven't had the time to complete one yet.  If you want me to carry on and do that, then just ask a new question and post a link to it here in this question.  I will get a notification and can go to the new question.


Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
topping2 challenge 13 80
tidtcpserver connection lost handle 2 70
Export Table to CSV - Access to CSV - using python 18 96
Device same like our heart 12 74
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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.
The goal of the tutorial is to teach the user how to use the cropping tool and to straighten there photos so it does not look tilted. You will choose which photo you want to edit, crop it to you liking and make it straight.
The goal of the tutorial is to teach the user how to remove a natural vignette your photos and how to add vignette to your photos.

919 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

21 Experts available now in Live!

Get 1:1 Help Now