[sane-devel] howto Duplex

abel deuring adeuring at gmx.net
Sun Feb 12 22:12:15 UTC 2006

Hi Horst, Hi Rene

Horst Herb wrote:
> On Sun, 12 Feb 2006 23:58, abel deuring wrote:
>>The Avision backend should have an option that enables the duplex
>>functionality. I have no idea what its name is, but you can ask a
>>Python-Sane device instance, which options are available:
> It has indeed, and I have no problems setting that property:
> scanner.source = 'ADF Duplex'
> I also notice from the scanner lights that it switches into Duplex
mode too
> while scanning with that option set
> What I can't do is retrieve the second image from the scanner -
only a single
> page image comes through instead of two

OK, next guess (Rene, can you as the author of the backend confirm

Perhaps the PIL source code file Sane/_sane.c is to blame. The
function SaneDev_snap expects that sane_start has been called, but
makes all other calls to the Sane library functions needed to
retrieve an image (sane_getparameters and sane_read) -- and finally
calls sane_cancel. This last call should optionally be disabled: I'd
guess that it "resets" the backend so that "backside data" of a
duplex scan is discarded.

If Rene confirms my guess, I can write a patch.


PS: IMHO, the "code separation" in PIL between sane.py and _sane.c
is a bit messy. If a missing "del sane_device_object" statement can
lead to a segfault, something is wrong in the code organisation ;)
Another point is that it is currently impossible to read the raw
scan data into some sort of Python sequence (string, tuple or list).
Of course its very handy to directly get a PIL image object via the
snap() method, but that's not necessary in every use case, and for
large scan resolutions and areas it can lead to huge memory consumption.

More information about the sane-devel mailing list