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

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.

Who is Participating?
BillDLConnect With a Mentor Commented:
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?
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.
nlpalmquistAuthor Commented:
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.
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

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.
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.
nlpalmquistAuthor Commented:
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.
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.

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.

All Courses

From novice to tech pro — start learning today.