Solved

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

Posted on 2011-09-12
7
466 Views
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.

Thanks
0
Comment
Question by:nlpalmquist
  • 4
  • 2
7 Comments
 
LVL 9

Expert Comment

by:tsaico
ID: 36526292
http://www.informatik.com/scanapp.html
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.
0
 

Author Comment

by:nlpalmquist
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.
0
 
LVL 38

Accepted Solution

by:
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.
http://www.irfanview.com

It is only free for non-commercial use, but needs to be registered and a "sum" paid to use it for businesses:
http://en.irfanview-forum.de/vb/showthread.php?1754-How-Does-One-Buy-IrfanView

It reads from and writes to TIF files without a plugin, although there are plugins for other formats available:
http://www.irfanview.com/main_formats.htm
http://www.irfanview.com/faq.htm#Q56
http://www.irfanview.com/plugins.htm

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?
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 38

Expert Comment

by:BillDL
ID: 36554575
I will also look at ImageMagick (http://www.imagemagick.org/script/index.php), 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.
0
 
LVL 38

Expert Comment

by:BillDL
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:
http://www.paulbradley.org/28/
http://freeimage.sourceforge.net/
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":
http://www.mail-archive.com/arie-l@u.washington.edu/msg02344.html
http://www.mail-archive.com/arie-l@u.washington.edu/msg02348.html
It's probably overkill and maybe very expensive.  I haven't read about it yet:
http://www.publist.com/ariel

Axommsoft Tiff Split Merge:
http://www.axommsoft.com/axom/tiff-split-merge.html
Not sure if there are command line options.
0
 

Author Closing Comment

by:nlpalmquist
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.
0
 
LVL 38

Expert Comment

by:BillDL
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:
http://www.xnview.com/en/xnview.html
http://www.xnview.com/en/nconvert.html

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.

Bill
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

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…
A short article about problems I had with the new location API and permissions in Marshmallow
The goal of the tutorial is to teach the user what exposure is and how to use the exposure slider. Analyze the photo that you want to edit, then adjust the exposure slider to your liking.
In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

708 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

11 Experts available now in Live!

Get 1:1 Help Now