[sane-devel] scanimage does not recognize basic long options

Karl Weber karl.weber99 at gmail.com
Fri Feb 3 20:11:11 GMT 2023


On Thursday, 2 February 2023 22:31:47 CET Karl Weber wrote:
> I get
> 
> scanimage: unrecognized option '--format=jpeg'
> 
> The backend used in this case is hpaio.

I know what is wrong and in particular why it works with the test device but 
not with hpaio. I know how to fix it in scanimage, but one might nonetheless 
consider it a bug in libsane-hpaio, not in scanimage. I am using libsane-
hpaio.so.1.0.0 from the openSUSE 15.3 repository.

It goes wrong in function static void fetch_options(SANE_Device * device); In 
this function the call to sane_get_option_descriptor(device, i) returns null-
values, i.e. SANE_Option_Descriptor stucts where name, title, desc, type, size 
and cap all are null values. These are inserted into all_options. I guess, the 
first NULL-entry in this array signals getopt_long the end of the options and 
all options after that are no longer recognized.

It is easy, to fix this. After

if (opt->type == SANE_TYPE_GROUP)
	continue;

one may to add

if (opt->name == NULL)
	continue;

and it works with hpaio. As I said, one might as well argue, that this has to 
be fixed in libsane-hpaio, but I do not know enough about the SANE API and 
what it requires in this case.

Regards
Karl

Just to give you an impression, here the output of all option processed in 
fetch_options for my scanner ScanJet Pro 4500 fn1:

SANE_Option_Desctiptor: name: mode-group, title: Scan mode, desc: (null), 
type: 5, size: 0, cap: 0
SANE_Option_Desctiptor: name: mode, title: Scan mode, desc: Selects the scan 
mode (e.g., lineart, monochrome, or color)., type: 3, size: 32, cap: 5
SANE_Option_Desctiptor: name: resolution, title: Scan resolution, desc: Sets 
the resolution of the scanned image., type: 1, size: 4, cap: 5
SANE_Option_Desctiptor: name: source, title: Scan source, desc: Selects the 
scan source (such as a document-feeder)., type: 3, size: 32, cap: 5
SANE_Option_Desctiptor: name: advanced-group, title: Advanced, desc: (null), 
type: 5, size: 0, cap: 64
SANE_Option_Desctiptor: name: (null), title: (null), desc: (null), type: 0, 
size: 0, cap: 0
SANE_Option_Desctiptor: name: compression, title: Compression, desc: Selects 
the scanner compression method for faster scans, possibly at the expense of 
image quality., type: 3, size: 32, cap: 69
SANE_Option_Desctiptor: name: jpeg-quality, title: JPEG compression factor, 
desc: Sets the scanner JPEG compression factor. Larger numbers mean better 
compression, and smaller numbers mean better image quality., type: 1, size: 4, 
cap: 101
SANE_Option_Desctiptor: name: geometry-group, title: Geometry, desc: (null), 
type: 5, size: 0, cap: 64
SANE_Option_Desctiptor: name: tl-x, title: Top-left x, desc: Top-left x 
position of scan area., type: 2, size: 4, cap: 5
SANE_Option_Desctiptor: name: tl-y, title: Top-left y, desc: Top-left y 
position of scan area., type: 2, size: 4, cap: 5
SANE_Option_Desctiptor: name: br-x, title: Bottom-right x, desc: Bottom-right 
x position of scan area., type: 2, size: 4, cap: 5
SANE_Option_Desctiptor: name: br-y, title: Bottom-right y, desc: Bottom-right 
y position of scan area., type: 2, size: 4, cap: 5
SANE_Option_Desctiptor: name: multi-pick, title: Multi pick, desc: Select 
multipick option for ESCL protocal based devices, type: 1, size: 4, cap: 69
SANE_Option_Desctiptor: name: (null), title: (null), desc: (null), type: 0, 
size: 0, cap: 0







More information about the sane-devel mailing list