Open ed2050 opened 2 weeks ago
Ed - Thanks for the feedback!
At a glance, I believe the issue is that scanline implements black and white scanning by telling your scanner to use a bitDepth
of 1 and a pixelData
type of bw
. I'm guessing your scanner doesn't have a mode that matches this. I don't see such a mode in the output above (thanks for including that!) but it's not immediately clear to me if that output includes all of the modes (it appears not, actually).
Two possible explanations for why it works with Image Capture:
1 -- Image Capture may be more savvy about the different ways that scanners report their capabilities. Maybe your scanner scans in black and white with a bitDepth of 2 for some bizarre reason.
2 -- Image Capture might have a fallback mode where if a scanner doesn't support black and white natively, it's done in software.
It's hard to tell without having access to the scanner to try some things. Are you able to do post-processing (maybe with ImageMagick?) to convert the scanned images to black and white?
Thanks @klep. Postprocessing works I guess. Scanning to pdf, so I need ghostscript not ImageMagick. I'd like to get it working with scanline though if possible. I also found that flatbed scanning doesn't work with scanline. Similar result as above.
I did some digging and found the SANE library works with the Officejet 4630. It seems their code uses 8-bit depth for grayscale, as noted by some of the comments. For instance see this driver:
/* Returns the data width that is send to the scanner, depending */
/* on the scanmode. (b/w: 1, gray: 8..12, color: 24..36 */
...
switch (sanei_hp_optset_scanmode(this, data)) {
case HP_SCANMODE_LINEART: /* Lineart */
case HP_SCANMODE_HALFTONE: /* Halftone */
p->format = SANE_FRAME_GRAY;
p->depth = 1;
p->bytes_per_line = (p->pixels_per_line + 7) / 8;
break;
case HP_SCANMODE_GRAYSCALE: /* Grayscale */
p->format = SANE_FRAME_GRAY;
p->depth = 8; // <-- COULD BE BIT DEPTH??
p->bytes_per_line = p->pixels_per_line;
if ( !sanei_hp_optset_output_8bit (this, data) )
{
data_width = sanei_hp_optset_data_width (this, data);
if ( data_width > 8 )
{
p->depth *= 2;
p->bytes_per_line *= 2;
}
}
break;
case HP_SCANMODE_COLOR: /* RGB */
p->format = SANE_FRAME_RGB;
p->depth = 8;
p->bytes_per_line = 3 * p->pixels_per_line;
if ( !sanei_hp_optset_output_8bit (this, data) )
{
data_width = sanei_hp_optset_data_width (this, data);
if ( data_width > 24 )
{
p->depth *= 2;
p->bytes_per_line *= 2;
}
}
break;
Can't tell if that's bit depth or data width they're setting. There's also BIT_DEPTH
var (or macro) in there but I haven't tracked down the source yet.
I also tried connecting to my scanner via mac ImageCaptureCore using the python-to-objc lib. I managed to make an ICDeviceBrowser object, set the search mask for Bonjour scanners, and start a device search, but so far it doesn't return any devices. I think the problem might be that it's expecting some kind of ICDeviceBrowserDelegate, but I don't know what delegates are yet (never used objc or mac APIs before).
Will report if I make more progress on this. Hoping to query the device myself to see what flags it expects.
Hey @ed2050 -- Thanks for following up.
In the Apple world, a delegate is an object that adheres to a defined protocol (what some languages would call an "interface"). So when the device browser finds a scanner, it'll call a function in the delegate. That said, I have no idea how to make a delegate work with a python-to-objc library.
I can try to create a branch where I use a bit depth of 8 for grayscale. And actually, the -bw flag is for black and white, not grayscale, so it wouldn't be what you wanted anyway. Not sure when I'll be able to get to it though.
If you have some time, you should try downloading and building scanline in XCode. You could experimentally change the -bw flag to look for a device mode with a bit depth of 8 and see if that works. Look at configureScanner
in ScannerController.swift
. And then to scan from within Xcode, you can look at and uncomment/edit the appropriate line in ScanlineAppController.swift
's init
. Then just run it from within Xcode.
Not sure what's up the flatbed. In the fullness of time, I'd also add a way to print out all the functional units of your scanner. 'Til then, a similar approach to above might be doable -- look at configureFlatbed()
Hi, this tool is exactly what I need to scan loads of old papers. Thank you for making this. ๐ ๐ At the moment it doesn't work quite right though...
Installed latest scanline binary from pkg. It finds the scanner ok:
Scanning seems to mostly work. If I do
scanline -resolution 200 -verbose
then all is fine. It scans from doc feeder and saves to ~/Documents/Archives.However sometimes there are errors. Notably:
And that's it. No docs are created in ~/Documents/Archive from above command.
Scanner is HP OfficeJet 4630 accessed on local wifi network. Two different macs recognize the scanner. Scanning from document feeder works fine with Image Capture app (b&w or color).
Any idea what's going on? Color files are twice as large as b&w, I'd really like to get it working.
scanline -h
. As far as I can tell, the OfficeJet scanner never makes any noise and is not accessed. scanline just creates an empty file. Wouldn't it be preferable to not to create any files in this case?Complete output