[sane-devel] Best way to stop scanimage?

Jeff jffry at posteo.net
Sat Sep 30 21:16:32 UTC 2017

On 29/09/17 15:52, Jeff Sadowski wrote:
> I am developing a php interface I'm calling it php saneng I have it on
> bitbucket for now and using proc_open. I will send the signal via

You are not the first. Have you looked at
https://sourceforge.net/projects/phpsane/ or
https://github.com/anomen-s/php-sane or https://github.com/sbs20/scanserv ?

I should probably point a few things before you continue down the dark
path of making a wrapper around scanimage.

When I started writing gscan2pdf back in 2006, it was exactly that, a
Gtk2 wrapper around scanimage, written in Perl.

It seemed like a good idea to wrap scanimage at the time, but it quickly
became clear that the problem is that you have no way of handling option
reloads. You can make it work for one scanner easily enough, but in a
general sense, it is impossible.

You are completely at the whim of the backend if an option, e.g. source
or depth, option force a reload. And they do, which changes unexpected
things. For instance some scanners support one page size (i.e. scan
size) for flatbed, and another for ADF.

You can work around this by calling scanimage [extra options] --help
every time the user changes an option, but this will be slow. You can
make it quicker by caching the options, but this is error-prone.

You will find that because of this, the order in which the options are
set is vitally important. i.e. for the above example, you have to set
the source option before the geometry options, as the range of geometry
options is changed by source. And confusingly, some backends have
different names for the same options.

In the end, I wrote Perl bindings for the SANE API. This solved all of
the above problems, as you then get reload callbacks:


However, it is non-trivial. Here is a tutorial on writing PHP extensions
in C:


Good luck.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://lists.alioth.debian.org/pipermail/sane-devel/attachments/20170930/4d3bf05c/attachment.sig>

More information about the sane-devel mailing list