Last weekend I decided to push forward an idea which has wrapped around my mind for a very long time. My family (I guess like almost everyone’s) has a lot of photos, notes, documents, etc. A lot of memories, packed into albums, envelopes, frames, or hidden somewhere between books on the bookshelf. Pictures fade or lose quality over time. That’s why I decided to scan them, but as there are a lot of them, I wanted to automate the process as much as I can.
Manual Process
The process is simple and can be broken down into the following steps:
- Insert a few pictures into a scanner. I want to scan multiple pictures at once to make the whole process faster.
- Scan using
Scan To File
button directly to the connected computer. - Let the script make the rest, so go to step 1.
The Script
- Watch scanner output directory.
- If a new image, use ImageMagick to crop multiple images from it and then deskew them if needed. Move results to a different watched folder for further processing.
- Convert images to jpegs and move to the output directory.
- Preserve scan somewhere just in case.
Sounds easy, right? Ok, maybe except cropping images and deskewing part, but thanks tothe Google
I found a glut of useful ImageMagick scripts. Those scripts are free, but only for non-commercial use, so mind your intentions. Of course, you have to have ImageMagick installed in the first place.
Gimmie Some Code
There isNode.js
mentioned in the title of this post, so Yes… I feel compelled to show some code ;). Here is the script code.
Default nodefs.watch
method gave me a big headache, that’s why I decided to go for chokidar lib.
The most important part is the usage of multicrop script. You can always modify parameters if you are not pleased with results.
Conversion to.jpg
is pretty straightforward.
You can find full project on Github.
Results
I am pretty happy with results. Of course, I need to rotate pictures accordingly later.
Post Production
Sometimes I need to discard a few of the result pictures because of additional “subpictures” extracted from the original one. There is an option for the multi-crop script to discard images smaller than a given size. You have to be careful scanning small pictures, though.
I found Google Photos pretty robust for simple post-production, including applying automatic filters and deskewing if the script doesn’t work perfectly.
Things to do
Port to Windows. I have windows machine somewhere ;]. I will update this post afterwards when it’s done.
Conclusions
I find this approach pretty fast and good enough for my needs. Maybe You Guys know a better and also FREE way? Let me know in the comments.