Command Overview

Top  Previous  Next

TwainSave can take various command line options.  The only required command-line option is -filename (the name of the image file to be saved).  Otherwise, TwainSave uses the default setting for the option if the option is not specified.  If TwainSave detects that an illegal command-line option is given, a dialog is displayed that has a summary of all the commands, and the TwainSave program is terminated.


When producing Acrobat PDF files, TwainSave has various options including setting the producer, keywords, encryption, and other useful PDF options.  The options that are PDF specific start named -pdfxxxx where "xxxx" is the option.


For some commands, an alternate version of the command option can be used.  The alternate version of the command is specified in brackets in the table of commands next to the command option.  For example, both TwainSave commands are equivalent:


twainsave -f test.tif -F tif1

twainsave -filename test.tif -filetype tif1



In the table below, the TwainSave options can be one or more of the following:



Specifies the acquisition area to acquire.



Sets the auto-brightness for the TWAIN device.



Automatically rotate documents to the correct orientation (must be supported by the TWAIN driver).


-autofeed  [ -A ]

Use the automatic document feeder (default is feeder is not used).


-autofeedorflatbed  [ -AF ]

Use the automatic document feeder, and if no paper is detected in feeder, use the flatbed portion of the device (detection of paper in feeder must be supported by the TWAIN driver).


-bitsperpixel [ -bpp ]

Bits-per-pixel used to acquire the image.

-brightness [ -B ]

Brightness level (must be supported by the TWAIN driver).



Sets the threshold (percentage) value for TwainSave to determine if a page is blank.  The threshold is the ratio of white pixels to dark pixels on the page.  Use this option with -noblankpages

-contrast [ -C ]

Set the contrast of the image



Sets the color setting of the device.  



Writes to a file all TWAIN device names and color/bits-per-pixel information for each TWAIN device.



Turns on automatic deskewing of images that may be distorted due to skewing.



Turn on diagnostic mode.



Log diagnostic messages to the specified file or to the active debug monitor.



Sets the order of directories that TwainSave will search to find the TWAIN DSM file (TWAIN_32.DLL or TWAINDSM.DLL)

-duplex [ -D ]

Use the duplex unit.  Default is to not use the duplex unit.


-filename [ -f ]

File name of the image file.
Unless the -details, -version, -uionly or -help option is used, the -filename option is a required command-line option.


-filetype [ - F ]

File type of the saved image.  Default is "bmp".  See -filetype for all the various file types.


-gamma [ -G ]

Gamma value used for the image.



Use a halftone (dithering) pattern for the acquired image file.



Display TwainSave help.



Highlight value used for the image.


-imprinterstring  [ -im ]

Sets the imprinter string.



Sets job control options.



Sets the JPEG quality factor for JPEG files.



Save all pages scanned to a multi-page file.



Save all pages scanned to a multi-page file only when the device user interface is closed.


Makes images acquired to be a "negative" of the original image (black or dark colors are light, and white or light colors are dark).



Discard any blank pages that have been acquired from the TWAIN device.


Do not open a console window when TwainSave starts up.



Do not display the TWAIN device user interface when acquiring pages.




Do not display the TWAIN device user interface when acquiring pages and wait for paper to be placed in document feeder to start the acquisition.



Maximum amount of time to wait for paper to be placed in document feeder before TwainSave shuts down.


Do not pause TwainSave if the file name is missing from the command-line.


-numpages [ -p ]

Number of pages to acquire.  Default is 0 (acquire all pages).



Specifies page orientation when acquiring pages.



Sets the device's overscan mode, allowing the device to acquire the part of the page that may lie outside of the acquisition area.



Specified the maximum number of unique files to create when

-overwritemode 3 is used.


Specifies what action to take if image file(s) already exists.


-papersize [ -P ]

Paper size. Default is US letter (8.5" x 11").



Turns on ASCII compression for PDF files.



Sets the PDF author setting for the file.



Sets the PDF Creator field in PDF files.



Turns on encryption for PDF file generation.



Sets the PDF Keywords setting for the file.



Sets the PDF owner password for encrypted files



Sets the PDF Permissions for an encrypted file.



Sets the PDF Producer field for the PDF file

(deprecated -- please use -pdfcreator).



Sets the JPEG quality used in PDF files.



Sets the PDF owner password to a random string.  This permanently disallows changing the security and -pdfpermit settings.


Sets the size of the PDF page.



Sets the PDF Subject field for the PDF file.



Sets the PDF Title field for the PDF file.



Sets the PDF user password for encrypted files.



Use 128-bit encryption for PDF files.



Sets the PDF orientation (landscape or portrait).



Sets the PDF scaling for the PDF file.



Sets the size of the PDF page.


-resolution [ -R ]

Sets the Resolution (DPI) of the acquired image.



Sets the rotation angle of the acquired image.



Save image file even if user cancels scanning.


-sd  [ -selectdefaultdevice ]

Select the default TWAIN device.



Sets the Shadow value for the TWAIN device.




Show progress indicator when using -noui.

-sn  [ -selectbyname ]

Select the TWAIN device by using the name of the device.


-st [ -selectbydialog ]

Select the TWAIN device by using the TWAIN Select Source dialog.



Denotes path where temporary image files will be stored.


Sets the Threshold value for the TWAIN device.



Produces thumbnail images.



Use the transparency unit to acquire from films, negatives and slides.




Sets the transfer mode used to acquire files from the TWAIN device.

-unitofmeasure  [ -U ]

Sets the unit of measure for the device (inch, centimeter, etc.)



Displays the device's user interface, but does not allow scanning or acquiring images.  Allows setting device options without scanning pages or acquiring images.



Allows the TWAIN device's user interface to remain visible after a set of images have been acquired.



Use version 2.x of the TWAIN Data Source Manager (TWAINDSM.DLL), if available.



Use the smart auto-incrementing feature when saving multiple pages to multiple files.



Outputs the TwainSave version in a message box.



Outputs to the screen or file the current action that TwainSave is executing.



Send -verbose output to a file.



Displays TwainSave version information.

-@  [-commandfile]

Use a command file to specify commands.


Here are a few examples of usage:


twainsave -sd -filetype bmp -filename mybmp.bmp

Selects the default device (-sd), saves to BMP format (-filetype bmp), and the name of the file is mybmp.bmp.


twainsave -filetype gif -filename mygif.gif

Displays the TWAIN "Select TWAIN device" dialog to select the device, saves to GIF format (-filetype gif), and the name of the file is mygif.gif.


twainsave -filetype tif3 -color 0 -filename mytifg3.tif -noui

Displays the TWAIN "Select TWAIN device" dialog to select the device (-sd), saves to TIFF Group3 format (-filetype tif3).

The color is set to black and white (-color 0) to ensure that Group 3 format is created correctly (Group 3 must use black and white).  No user interface of the TWAIN device is displayed.


twainsave -contrast 20 -filename mybmp.bmp

Acquires to a BMP file and sets the contrast of the image to 20.


twainsave -contrast 20 -filename mybmp.bmp -uiperm

Same as above, except that the TWAIN user interface for the device does not close after a set of pages are acquired (the user must close the user interface).


twainsave -papersize A4  -filename mybmp.bmp

Display the TWAIN "Select TWAIN device" dialog, acquire to a file called mybmp.bmp, and use the A4 paper size.  The device must support A4 paper sizes for this option to be successful.


twainsave -sn "Fujitsu Twain Driver" -bitsperpixel 8 -filetype tif7 -filename mytif.tif -noui -duplex

Uses the TWAIN driver named "Fujitsu Twain Driver",

bits-per-pixel is 8

Save to TIFF-LZW format

Name of the file is mytif.tif

Do not display the user interface of the device

Use the duplex unit.


twainsave -verbose

Uses defaults and displays the progress of the acquisition on the screen.


twainsave -@ "mycommands.txt"

Uses the command file called mycommands.txt.  This file contains the actual TwainSave commands to use.


twainsave -filename test.bmp

Just specifying the filename does the following defaults:


Show the TWAIN "Select TWAIN device" window to select the TWAIN driver.
Displays the TWAIN driver's user interface.
Acquires entire page to a Windows BMP file.
The color used is black and white (1 bit per pixel), or the first available color that the TWAIN device supports that is compatble with BMP files.
Closes the TWAIN user-interface displayed after acquiring the image (see the -uiperm option to leave the user interface displayed after an acquistion)
No verbose output.


Note that some options may cancel out other options.  For example, an option to specify the PDFpage size (-pdfsize) will override the -papersize option.  Make sure that you choose options that do not conflict with other options in terms of functionality.


Also note that many of these command-line options can be overridden by the user of TwainSave if the TWAIN user interface of the device is displayed (if you do not specify -noui) .  For example, if you specify on the command-line to use color (the -color 2 option), and the user changes this by selecting a different color type in the user interface, TwainSave cannot override the user's choices, and will attempt to scan and save the image based on the choices in the user interface.