This Time Self-Hosted
dark mode light mode Search

Scanning documents with the GT-S50

You might remember that a couple of months ago I bought a high-end scanner for my ongoing mission to make my office as paperless as humanly possible to me.

In due time, I also replaced my previous scan2pdf sh script with something a bit more reliable, written in Ruby. The original reason was that the options supported by the four scanners I have worked with up to now – an Epson Perfection 2480/2580, a HP OfficeJet MFP with a “fake feeder”, a HP LaserJet network MFP, and now the GT-S50 – varied considerably, and I needed something that would actually allow me to choose the options to pass depending on the device itself. The end result is a Ruby script scan2pdf which is still not implementing all I wished for, but it comes much nearer than what I used before.

One of the most recent features came from a requirement I found when trying to get rid of some legal paperwork from some years ago: for whatever reason, in Italy, a number of legally-binding papers seem to still be printed and set in folded sheets (what is usually called foglio protocollo in Italian); this means that you got a single A3-sized sheet, folded in the middle to provide four A4-sized sides to write on. And actually cutting this down to reduce it to two A4 sheets is not an option. How do you scan that?

With a standard flatbed scanner it is relatively easy to scan it: you just scan the four sides one by one. On a sheet-fed scanner like the GT-S50, you can’t do so unless you use the plastic envelope that they give you, which allows to scan irregularly-shaped sheets. And even doing so, it is a bit of a problem because you either have to run four scans, or you have to interleave the external and internal sides. So the end result was implementing a --folded switch to the script, and there you go.

What I’m missing now is some kind of “presets” system, so that I don’t have to repeat the same options each time when I’m doing common scans: a folded scan requires me to use the envelope, which in turn means that the first 20mm of the scan need to be discarded (as it’s the envelope’s detection zone). And all the scans from the GT-S50 (as well as the Perfection 2580) are to be done in the middle-area, rather than starting from the far left or right (as it was done, instead, on the HP MFPs.

For this one, I’m actually open to suggestions: do anybody know a decent Ruby library to handle ini-style configuration files? I’m not keen on using YAML here, not only because I can’t stand the format, but also because it seems more natural to keep using the key/value pair files when there is no need for anything particularly complicated (multiple sections are welcome for presets themselves).

Comments 4
  1. How about JSON?It’s not quite a drop-in replacement for YAML (no JSON in the Ruby standard library yet, IIRC), but it meets you ini-style, key-value pair requirements.

  2. I agree with phillip, you should take a look at JSON, maybe ruby already provides something to automatically create objects from JSON like JS does. On the other hand, is there a paritular reason to use ruby? Maybe python provides what you need. If by ini-style you mean something like samba config file you should be able to write a parser in a matter of hours.

  3. I’m not much of a JSON fan; even though it should work for what I need, it’ll require me dictionaries and I’d have rather avoided that. But I’ll consider it, better than nothing and better than YAML at least.Patrik, I dislike Python with a passion, mostly because I can’t get rid of the feeling of needing an explicit “end” keyword. The particular reason is thus “Ruby is my language of choice, full stop”…

Leave a Reply

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