Scanning with ptal-hp

The ptal-hp command-line utility supports scanning on the OfficeJet 500, 600, 700, T, PSC 300, LaserJet 1100A, 1220, and 3200 series, which are not yet supported by SANE.

Syntax summary

Here is the "ptal-hp scan" syntax, derived from the built-in help messages:
ptal-hp <dev> scan [-help] [<settings>...]
<dev> is the PTAL device name
Valid settings:
  -bw, -bwht, -gray, -color       -- Scan mode (default=color)
  -contrast <contrast>            -- Contrast (0-100, default=50)
  -res <xy>, -xres <x>, -yres <y> -- Resolution (default=100 DPI)
  -raw, -jpeg                     -- Compression (default varies)
  -compfactor <n>                 -- JPEG compression factor (0-100, default=0)
  -length [+|-]<n>                -- JPEG image length or +/- delta
  -o <filename[.ext]>             -- Output file (default=out.pnm or out.jpg)
  -keep                           -- Don't delete output file on error
  -multi                          -- Scan multiple pages
  -pagenum <n>                    -- First page number (default=1)
  -pagenumdigits <n>              -- Digits for page number (default=2)

Notes and explanation

Scan modes: The best supported scan mode is the default, which is color for most models, but gray for the OfficeJet 500 series and LaserJet 1100A, which don't support color scanning.

The resolution defaults to 100 DPI (dots per inch) in most cases. However, some models only scan at 300 DPI in certain modes (bw/bwht/gray for OfficeJet 500 series and bw/bwht for OfficeJet 600/600/PSC300/700 series). In these cases, 300 DPI is the default; scanning at any other resolution may cause the device to lock up and/or display a "SYSTEM ERROR" message. ptal-hp invoked with the -help switch attempts to query the list of supported resolutions as reported by the peripheral. Also, since the set of supported resolutions on these devices typically consists of discrete values instead of a continuous range, the device may substitute the nearest supported resolution if you specify (or default to) an unsupported resolution.

-res changes both the X (horizontal) and Y (vertical) resolution. The -xres and -yres options adjust these parameters separately, but this capability probably isn't very useful.

-raw and -jpeg may be used to force uncompressed .pnm output or compressed .jpg output, respectively, which also changes the default output filename. However, both raw and JPEG compression aren't necessarily supported in all modes on all models:

If you're using JPEG compression, the -compfactor switch may be used to adjust the compression factor. Smaller numbers mean less compression but better image quality, and larger numbers mean more compression but worse image quality.

The -o filename.ext switch specifies the output file, which defaults to either out.pnm or out.jpg, depending on the compression setting. If you don't specify a file extension, or if you specify the wrong extension for the explicit or implicit compression setting (-raw or -jpeg), then the extension is automatially set to the right value.

Multi-page (batch) scanning is enabled with the -multi switch. In this mode, the output filename is modified to include a page number before the extension. If necessary, the starting page number may be changed with the -pagenum switch, and the number of digits for the page number may be changed with the -pagenumdigits switch.

By default the image length/height is detected based on input from the device, or in the case of JPEG by parsing the compressed data and counting the raster lines. For JPEG scans, you can use the -length switch to override or adjust the image length/height. If the following number is unsigned (lacks a leading '+' or '-'), then it is taken to be the absolute image height regardless of the auto-detected height. On the other hand, if the number starts with a '+' or '-', then it is taken as a delta which increases or decreases the auto-detected height. You may find it useful to subtract a few lines to remove the gray line at the bottom which is the result of scanning the end of the page. Note that if you add any lines or subtract too many lines (more than 15 for color or more than 7 for gray), then your image viewer/editor may report a "Corrupt JPEG data" error message followed by either "premature end of data segment" or "extraneous bytes before marker 0xd9".

Examples

	ptal-hp mlc:par:0 scan
	ptal-hp mlc:par:0 scan -gray
	ptal-hp mlc:par:1 scan -res 300
	ptal-hp mlc:usb:HP_LaserJet_3200 scan -jpeg -o foo.jpg -length -15
	ptal-hp mlc:usb:HP_LaserJet_1220 scan -multi
	ptal-hp mlc:usb:0 scan -multi -pagenum 98 -pagenumdigits 3