This Time Self-Hosted
dark mode light mode Search

Frontends to command-line or libraries?

I know I’m still convalescing so I should be resting, not thinking about development problems, but this is something that ended up in my mind because I have one thing to absolutely do (scan the release documents from the hospital to send to my GP), and for which I miss an easy interface I could instruct my mother, or my sister, to use.

Don’t get me wrong, I know there are a few SANE frontends, starting from xsane itself, but the problem is that I don’t usually stop at scanimage when I do it from the console. What I usually do is to launch a batch scan to TIFF format, then use tiffcp to join the different TIFF files in a single file with multiple pages, and then use tiff2pdf to convert it to a PDF file, which is opened by any computer I might need to send the data to (and it also is quite smaller than the original TIFF file). Lately, I’ve started trying to add to the chain also unpaper, a tool that removes some of the defects usually found in scanning pages from books (like black borders and similar), which works on PNM (thus requiring a change in the scanning command, and a further conversion later on).

But I don’t want to start fleshing down how to actually write such a tool, or I might actually start writing it right now, which is not what I’m supposed to do while I’m convalescing.

What I want to think about is that here comes one huge debate between writing frontends for command-line tools, which just interfaces with them as process calling, or writing a full-fledged program that interfaces with the low-level libraries to provide similar functionalities.

I already happen to discuss that quite often since xine and mplayer embody the two spirits: xine has its library, frontends interface with that, and a single process is used; mplayer instead has a command interface, and frontends execute a new process for playing videos.

There are of course advantages and disadvantages, one easy to spot disadvantage to xine’s approach is that a crash or freeze in xine results in a crash or freeze of the frontend, which is something Amarok users have been unfortunately familiar with.

In the case of the scanning toolchain, though, I guess it’d be probably easier to use a frontend for the tools, as re-implementing all the different functionalities would be a non-trivial work.

The disadvantages of doing it this way, though, is that you’ll have to make sure that the tools don’t change their parameters between versions, otherwise it’d be a problem to ensure the correct functionality of the tool. Also, the tools need to provide enough options to control with granularity the execution of their task, which is something unpaper actually does, but in turn makes them almost unusable for final users.

I know I’m not going much anywhere with this post, I’m afraid, but I just wanted to reflect on the fact that to have a command line tool designed to be used by frontends, you almost certainly make its syntax so complex that users would fail to grasp the basic concepts, and in turn, you’d need a command line interface to the tool too… which is why there are so many scripts interfacing to ffmpeg for converting videos, I guess.

On the other hand, one can easily write such a frontend using scripting languages, even if it’s graphical, such as with ruby-gtk2 (think RubyRipper).

Comments 3
  1. Thanks for explaining how you scan your medical documents.I’ve been trying to think of methods to batch scan in the thousands of pages contained in my medical records and worker’s compensation files for years.I want to have OCR added too for enhanced text search capabilities so I can run reports.FWIW, command line stuff tends to be the most open. Can’t go wrong with POSIX. :p

  2. I just wish there was an easy way to deal with the buttons on my scanner so that they’d be seen as events by the kernel, so I wouldn’t need to get around the desk to press enter to scan the second page :(I could replace the scanner, but it’d be fourth since I started owning one, and for what I use it it’s not really worth it.Actually I replaced it earlier this year, but I bought the one I have now second hand on eBay, and it replaced an almost identical one (I used to own an Epson Perfection 2480, which worked quite nice on Linux for documents and OSX for negatives/positives, but replaced it for a 2580 — just the lid differs — to have it scan negatives more easily (on OSX of course); it wasn’t too bad as my sister had to replace her scanner, so I gave her mine and I bought the one second hand, which made the whole a good deal for what I paid it).I haven’t tried OCRing anything yet, I don’t usually need that but I guess it might be useful from time to time. But the important part for me is to have the scan in a format even an MD can read.. seems like most of them hate computers from inside.

  3. Hi,There’s gscan2pdf, although you’ve probably heard of that already.http://gscan2pdf.sourceforg…It’s a very nice frontend that normal people can use, too. :)Gscan2pdf does have unpaper and OCR integration, but nothing for scanner buttons if they are not already supported in SANE. The buttons on my Canon LiDE 60 aren’t, unfortunately.I hope you can rest. After all you’ve been though, I’m sure your body needs all the convalescence it can get.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.