[sane-devel] Perl Bindings

m. allan noah kitno455 at gmail.com
Tue Nov 11 21:36:41 UTC 2008


On Tue, Nov 11, 2008 at 3:11 PM, Jeffrey Ratcliffe
<jeffrey.ratcliffe at gmail.com> wrote:
> I've finished transliterating scanimage and scanadf into Perl.
> Everything works as in the original apart from a funny discrepancy:
>
> $ scanimage -d test -t 1 -l 2 -x 21 -y 32 --batch-count=2 -v -v -v
>
> gives me in 1.0.19:
>
> scanimage: value for --tl-y is: 1
> scanimage: value for --tl-x is: 2
> scanimage: value for --br-x is: 21
> scanimage: value for --br-y is: 32
> scanimage: rounded value of br-x from 23 to 23
> scanimage: rounded value of br-y from 33 to 33
> Scanning 2 pages, incrementing by 1, numbering from 1
> Scanning page 1
> scanimage: scanning image of size 41x62 pixels at 8 bits/pixel
> scanimage: acquiring gray frame
> scanimage: min/max graylevel value = 255/0
> scanimage: read 2542 bytes in total
> Scanned page 1. (scanner status = 5)
> Scanning page 2
> scanimage: scanning image of size 41x62 pixels at 8 bits/pixel
> scanimage: acquiring gray frame
> scanimage: min/max graylevel value = 255/0
> scanimage: read 2542 bytes in total
> Scanned page 2. (scanner status = 5)
> Closing device
> Calling sane_exit
> scanimage: finished
>
> Ignoring the fact that the verbose output for --br-x and --br-y should
> be for x and y,
>
> scanimage: rounded value of br-x from 23 to 23
> scanimage: rounded value of br-y from 33 to 33
>
> a. weren't 23 and 33 to start with
> b. weren't rounded.
>
> What's going on? I ask, because the Perl version, which I wrote to be
> as near to identical as possible, doesn't show this behaviour, and
> therefore ends up with a smaller image. In C, it is almost as if the
> --tl-y and --tl-x values are getting added twice.
>

this is one of my BIG pet peeves with the sane standard. most scanners
think in terms of left offset and width, but the sane standard
requires that the backend expose options for left offset and right
offset, where right offset (br_x) is left offset+width. Them, the
authors of scanimage, in their infinite wisdom, decided to expose to
the user: left offset and width!

then, under the hood, scanimage converts your commands like so:

-l 2 -x 21 = --tl_x 2 --br_x 23
-t 1 -y 32 = --tl_y 1 --br_y 33

The rounding messages are caused by something returning
SANE_INFO_INEXACT are you checking the info in perl?

allan
-- 
"The truth is an offense, but not a sin"



More information about the sane-devel mailing list