Are you having trouble getting scans to be the right size?
I’ve had a few people recently report that their document scans were coming out full size instead of the correct paper size.
One person was doing a web-based solution – document scanning within the browser! (That really impressed me as we seem to be locking things down these days rather than making them more useful. There are important concerns so I’d never thought anyone could navigate through that; but he did.) I suspect there were many problems in getting to that point but the only problem remaining was the scans were coming out the wrong size.
My best guess was that the scanner they were using was ignoring the ICAP_SUPPORTEDSIZES TWAIN command. Programs such as CmdTwain use that to set the scan size to match standard paper sizes.
There was another person doing small scans. I’m guessing it was of business cards or receipts. He liked the fact that the scans took less time when you scanned smaller sizes. If you have a lot to do then even small speed improvements add up. In these sorts of cases though, you can actually double or triple your processing speed by using smaller scans. However, the document scanner stubbornly ignored the paper size parameter.
Under the Hood
The ICAP_SUPPORTEDSIZES command was introduced in version 1.0 of the TWAIN standard. It has been there since the beginning. It is supported in every version of the standard since then.
The TWAIN 2.2 standard from 2012 says ICAP_SUPPORTEDSIZES is "Required [to be supported] By All Image Sources that support fixed frame sizes" and "Most scanners support ICAP_SUPPORTEDSIZES". The main exception seems to be cameras as they take pictures in pixels rather than scanning things that occupy a fixed number of inches or cm, wide and high.
Whilst it is surprising that scanners are appearing that don’t respond to this command, you can usually get around it. If the scanner has any ability to do different sized scans at all, then if it doesn’t support ICAP_SUPPORTEDSIZES, it must support DAT_IMAGELAYOUT. This can be a bonus as you aren’t limited to fixed paper sizes. You can scan any size you want.
Every document scanner that meets TWAIN Specification 1.5 or later is REQUIRED to support DAT_IMAGELAYOUT. Version 1.5 of the TWAIN Specification was released in May 1993 so, as at the date this is being written (2016), any scanner built in the last 20 years should allow the DAT_IMAGELAYOUT command.
With CmdTwain, the option to send a DAT_IMAGELAYOUT command to the scanner looks like this:
C:\> CmdTwain -c "xywh 0.0 0.0 3.0 5.0" 75 small.jpg
The xywh parameters set the top left corner and width and height of the scan. In most cases you’ll use 0.0 and 0.0 for the top left corner and set the width and height to match the size of the scan you want. The size is in the current scanner units so you can precede the command with "in" or "cm" to tell the scanner to use inches or centimeters. Having said that, I’ve also seen some scanners that don’t understand "cm". Both "in" and "cm" also date back to the original standard and all scanners are required to support the ICAP_UNITS command (used to select inches or cm). However, they are not REQUIRED to support anything other than inches. The TWAIN default is to use inches.
If you are having trouble getting your document scanner to scan a specific paper size, I suggest using the xywh option and using inches for the width and height. Some examples are:
A4 is 21.0 x 29.7 cm = 8.2677 x 11.6929 inches.
C:\> CmdTwain -c "xywh 0.0 0.0 8.268 11.693" 75 a4.jpg
US Letter is 8.5 x 11.0 inches.
C:\> CmdTwain -c "xywh 0.0 0.0 8.5 11.0" 75 letter.jpg
A5 is 14.8 x 21.0 cm = 5.8268 x 8.2677 inches.
C:\> CmdTwain -c "xywh 0.0 0.0 5.83 8.27" 75 a5.jpg
If you’d like to see what your document scanner supports and doesn’t support: download, unZIP, and run ScanTest.
Interestingly, my scanner appears twice in the list of twain sources (C:\> ScanTest /source). When I select the version prefixed with Windows Imaging Architecture (WIA), all of the ICAP_SUPPORTEDSIZES fail and the only ICAP_UNITS command that works is for “inches”. When I select the other scanner (same device but not via the WIA driver), the paper sizes and cm commands work fine. I’m using an Epson scanner on Windows 8.1 with a Microsoft WIA driver.