Close
0%
0%

Simple Sane.d front-end for OSX

A simply front end to use a networked scanner on a Raspberry Pi from an OSX machine.

Similar projects worth following
Making a simple front-end to use a shared scanner via sane on OSX using simple tools and a simple interface.

(It was pointed out but Jeff Stearns that the ZIP package contains a very old version of Libusb for OSX. If you want to try Scanity 1.1, perhaps check for newer available versions of both Libusb and the sane.d back-end).

While thrifting, I found a nice flatbed scanner for a 5 euro's. A nice compact Canon LIDE 220, which apparently is still available new! We haven't had a decent flatbed scanner for years as we mostly use camera scanning software on iPads and such, but sometimes it is nice to be able to scan at flatbed resolutions.

My plan was to place this scanner in the network by sharing it via the sane project on a raspberry pi. Surely, how hard would it be to use that shared scanner on other non-linux machines? Well, it turned out to be frustrating and eventually in need of a hack.

Now setting up sane is trivial. It is a perfectly managed software package that does a fantastic job of supporting a ton of scanners, old and new. Basically it is CUPS for scanners. So on my desktop development pi, I had the scanner up and running in minutes. Good, so now for the OSX side of the equation.

There is a project that promised to expose a sane'd scanner to the TWAIN interface that OSX uses. The TwainSane project. Basically it is the sane project for OSX with some glue logic to attach it to the relevant interfaces. Problem is, the project is in disrepair and even worst, it does not work! The sane part is fine, it sees the scanner on the network and the various attributes it understands, but it simply does not provide a device to the various applications like image capture or photoshop. Well, that makes the whole endeavour pretty pointless!

Using imagescan from the command line, it was clear that it was perfectly possible to scan an image over the network, but other application would have non of that. There was one exception though. Libreoffice did somewhat support the sane environment and presented me with a basic scanner window with previews, settings and other options. The problem however was that is was pure garbage. It did work somewhat, but setting could not be altered because the interface was a mess. This and the failure of the twain interface started a trend. A trend that I have seen all to often in open source. The failure of making something simple work.

I tried a couple of frontend packages and all failed in one way or another. Either being completely unable to find the scanner, when it was apparent that it was working perfectly fine, and in some cases, finding the scanner, but being unable to use it for some daft reason. All the front ends (including xsane, which I installed via brew as a final ditch effort) were frustrating and useless. Most of them have not seen updates in 3 to 5 years. I have a theory why that is and why sane is such a quality project while all frontends are pure unadulterated spittle.

For Linux, if you want to scan a document in any capacity, you probably end up using the sane project. As I said, sane is to scanners what CUPS is to printers. But this isn't true in the windows or mac realms. Here the majority of scanners are combo devices that provide an interface via their driver. There is no need to have a all encompassing environment that can cater to every scanner users needs. With the arrival of cheap printer scanner combination units, the need for a robust frontend for sane on non Linux platforms simply vanished.

This left me with 2 options. Either use some web based sane interface which would give laptops and tablets access to a web interface that controlled the scanner. This of course is extremely ugly, or make some sort of front end that is more OSX like.

Sanity.zip

Sanity1.1 Extended menu version + Libusb + Sane backend + sane pref panel.

Zip Archive - 9.19 MB - 06/16/2020 at 11:17

Download

Scanity1.1.dmg.zip

Scanity 1.1 OSX front-end for sane scanners.

Zip Archive - 447.91 kB - 06/15/2020 at 14:23

Download

  • 1 × Canon Lide 220 The scanner, but any old scanner will do.
  • 1 × Raspberry Pi 3 Runs the printer and scanner server
  • 1 × A computer running OSX To run the front end on of course.
  • 1 × HP5N My ancient printer with auto power on hack

  • Installation update.

    Timescale11/05/2020 at 13:16 0 comments

    Turns out, the package installer for libusb and probably the sane.d installer package as well, are outdated versions that do not run well on MacOS Catalina.

    Thanks go out to Jeff Stearns for directing my attention to that.

    I included these package installers out of convenience because they do not require brew to install, but I did not check the versions against the official projects. Basically these are the same installer packages I used when trying Twainsane. But as these are quite old and do not run on newer MacOS instances, my advise for installing Scanity is to use Brew to install the latest and greatest versions of libusb and sane.d and not the included package installers.

    Scanity itself is completely version agnostic regarding libusb or sane.d and should run fine until Apple pulls the plug on Intel binaries or drastically alters the menubar system. That's when we'll need a Scanity 2 I imagine.

    I have thought about it and decided to leave the zip with the old installer packages up for instances where people might want to use older MacOS versions and have trouble with using Brew, but for relatively new machines, use brew to install LibUSB and Sane.d and then drag the scanity app to applications.

    If the options from the pulldown menu do not work, use "show package contents" and move the Scanity.app and other .app files outside the package. Calvin Walden found this problem and subsequent solution. In possible future versions, this will work better. 

  • Demo of my setup

    Timescale06/17/2020 at 11:54 0 comments

    A short demo of my setup as it stands now.

    The printer used is my trusty ancient HP5N connected to a RaspberryPi 3B via a parallel-to-USB adapter. The Pi is running CUPS and Sane.d and also some hacks that power on my antique laser printer which was covered in THIS project on Hackaday.io.

    The scanner is a Canon LIDE 220. A small budget unit that conveniently is powered via USB. The buttons do not work because the button-daemon interfered with the network sharing. The front-end software however does all we need it to do.

    First I use the front end to scan a colour document directly to preview.app and then I scan a document in black and white directly to the printer.

  • First deployment

    Timescale06/16/2020 at 11:17 0 comments

    After implementing a couple of features like lineart scanning and the option to scan to printer in grey and lineart modes, I thought it time to install the package on another macbook used around the house.

    Installation isn't a typical drag and drop affair because there are some packages that need to be installed.

    • Libusb
    • Sane back-end
    • Sane preference panel

    All need to be installed, sane back-end needs to be configured to see your sane server and app security needs to be able to open anything before starting sanity. But if those conditions are met, the menu app starts up and should work.

    For convenience I have uploaded a zip file with the sanity app and the software versions of Libusb and sane I used. While still the 1.1 version, this sanity install also has the option to scan lineart to screen and printer.

  • Version 1.1

    Timescale06/15/2020 at 14:30 0 comments

    Version one worked fine for people with the same user name as me! Rather a niche audience I feel. Yes, a path was hard-scripted in one of the files!

    Version 1.1 fixes that and adds the direct to printer option which will scan a document and then push it via CUPS to the first or default printer. For my printer, I had to tweak the brightness level to get a good white, so depending on your hardware you might want to tweak that or other values.

    The script for the scanity console is located in the app package/contents/resources/scanity.app/contents/resources/script

  • Platypus

    Timescale06/14/2020 at 13:58 0 comments

    So I want to make a front end that feels somewhat native to OSX. It should be simple and accessible. Seeing how stable and flexible the command line tool scanimage was working, I wanted to base it on that. So really all that I need to a nice dock or top bare menu item that calls scanimage in various ways. Not something I think firing up xCode for.

    I remembered there was a software package that allowed to attach various scripting languages to a cocoa GUI environment called Platypus. It is not a full development environment, but it is really convenient if you want to start and control bash, python, perl or just about any scripting language with a nice interface. It outputs a small and elegant OSX app package that should work on any mac OSX 9 or higher.

    What I did was really really simple. Basically I made 2 platypus apps. One is a bar menu object that presents the user with a couple of scan options. The second is an app that takes the necessary arguments runs the bash commands to scan an image and open the result in preview.

    You can download the DMG file from the file section. It should work with any Mac with OS9 or higher and it should be able to work with any sane configuration as long as a scanner is detected.

    Now it is still a bit hacky and rough around the edges, but altering the script behaviour is really easy, even without the Platypus profile data. The various scripts are editable in the resource package and that is the bulk of the behaviour.

    Newer versions and the platypus profile will be available later.

  • Scanity

    Timescale06/14/2020 at 13:30 0 comments

    Turned out the sane web interfaces were as horrid and frustrating as the other ones, so there is nothing left to do but to either build a working front end or use the scanner in a sub optimal way that will certainly result in the machine being dumped in the attic at some point.

    Now, what do I want when interfacing with a scanner on a mac? Do I want the same scanner interface I have seen since the first flatbed scanners I owned in the 90's? Those massive windows with a thousand options? No! The reason scanner software worked like that back then was because processing speed and storage where a thing. If you did not need to scan 1200DPI full A4 full colour uncompressed, then you tried to avoid it. Made sense then. Not now. Even with USB2 speeds and a moderately capable network, the loads are negligible.

    It is perfectly reasonable in 2020 to simply request the entire page on any resolution and crop it afterwards. It is just as quick and far more convenient.

    So, on a mac, what would be the ideal way to use a flatbed scanner? A simply short list of options that result in either a text or an image document opened in a suitable application. Basically I want to quickly command the scanner to scan 300DPI in greyscale and open it in preview where I can crop and save. That is all you really need for 99% of the time.

View all 6 project logs

Enjoy this project?

Share

Discussions

jeff stearns wrote 10/31/2020 at 01:39 point

Thanks for sharing this project.

I notice that Sanity.zip contains libusb version 0.1.13beta.  The current libusb version is 1.0.23.

This seems odd.  Can you explain a bit why you're using what looks like a very old version of libusb?  Thanks!

  Are you sure? yes | no

Timescale wrote 10/31/2020 at 12:36 point

Whoopsy! I believe I got these via a link from the Twainsane website. Never even crossed my mind to check these libs for newer versions.

I'll include newer versions in the next "version". Or perhaps, leave them out with links to the project pages.

I suspect everything still works fine with 1.0.23, but if you try, let me know!

  Are you sure? yes | no

jeff stearns wrote 11/04/2020 at 05:10 point

libusb version 0.1.13beta doesn't work properly on MacOS 10.15 Catalina.  That old version of libusb can't connect to a Fujitsu ScanSnap fi5110EOXM.  This prevents Scanity from working with that scanner on Catalina.  Upgrading libusb to version 1.0.23 fixes the problem. 

  Are you sure? yes | no

Calvin Walden wrote 09/12/2020 at 23:07 point

Thanks so much for sharing this project! Scanity1.1 works perfectly for my setup:

Scanner and server: Raspberry Pi 3 B, running Raspberry Pi OS Buster, Canon CanoScan LiDE 60 via powered USB hub
Client: MacBook Pro running macOS 10.15 Catalina, with libusb installed via brew, and the SANE backends and preferences panel packages downloaded directly from Mattias Ellert's website.

The only snag I hit was that ScanityMenu.app had to be copied to the Applications folder before selecting the menu items would actually cause Scanity to open.

  Are you sure? yes | no

Timescale wrote 09/20/2020 at 16:28 point

Glad to hear you found some use for it.

I have had varying results with the packages after install. Sometimes moving them to the application folder, running the main .app and then moving them back solves the problem as so far as it is an actual problem.

I think there is an terminal command with which I could put the .app's into the required "index", but I have not looked at that option. Perhaps for version 1.2.

  Are you sure? yes | no

Ken Yap wrote 06/16/2020 at 11:49 point

>This left me with 2 options. Either use some web based sane interface which would give laptops and tablets access to a web interface that controlled the scanner. This of course is extremely ugly, or make some sort of front end that is more OSX like.

I think a 3rd option is to run Xsane on the RPi and connect to it using VNC from your Mac and other OSes, including Linux.

Actually on Linux, I use simple-scanner instead of Xsane since all I do is scan the occasional paper form.

  Are you sure? yes | no

Timescale wrote 06/16/2020 at 19:46 point

Indeed and the RPi3B printer/scanner server I have implemented this on does run a desktop (which I almost never do), VNC and in my case gscan2pdf just to have that option as well, but we'll probably not use that because it adds many steps and makes getting the data far more fussy.

Doing that on my Desktop RPi4 or other Linux machines makes little sense as it also runs sane and that works perfectly over the network. It's the front ends for OSX that suck the ever living joy out of life.

I have also installed scanserv on the LAMP stack which provides quite a feature complete scan interface as a web application. This, at the moment, is how I choose to scan via iPads or phones. In a pinch, that would work nicely.

But the majority of graphic intensive work in our household is done on a small armada of Macs, so to have a quick and easy way to scan something in such a way where it would neatly fold into existing workflows on each machine (of which preview is an essential part) was the main goal.

So, yeah! I got a ton of options right now to scan documents and graphics, but I expect the "push a button and get an image in preview" solution will be the most popular.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates