Saturday, August 4, 2012

How To Automatically Scan And Crop Your Card Scans

1986 Donruss-your scanner's worst enemy

Do you find it rather tedious to scan your cards?


Alright, stupid question.

Wouldn't it be sweet to just hit one shortcut key and have it done for you?

If your using Ubuntu or other Debian-based distro I'll show you how.

Sorry for the spacing on this post. Blogger is killing me today.

 I use a HP All In One printer. You might have to adjust the pixels referred to below to obtain optimal results for your scanner.

Step 1:

Go this short but excellent article and give the instructions a quick look over.

Don't worry if you don't understand some or most of it(like me).

Make sure you do have sane and imagemagick installed as the program that actually is used is part of these programs.

Open a terminal window and copy and paste the green text below to install them on your system:

sudo apt-get install sane imagemagick
That's really all you need to do as far as the instructions go. 

Step 2:
Download the photo_scan.sh_.tar.gz  file at the bottom of the page.

Step 3:
Extract the file to wherever you want. 
Make it executable by right clicking and going to Properties>Permissions>
 Checking the execute button next to Owner.
If you want to see it in action in an unedited state, just drag and drop onto a terminal 
 window and hit enter.
You can probably see why it needs to be edited before it's useful for our purposes.
We don't need 3 sizes in our folder, we just need the familiar 3.5X2.5 size.
Step 4:
Open with your text editor, mine being Gedit.
This is what it will look like:

Step 5:

This is where you need to pay attention.

As you'll want to be have quick access to the directory it makes I have changed it to 
Desktop instead of Documents.

Here is my altered file input:


cd ~/Desktop

IMG_DIR=`date +%m-%d-%y_%H.%M`
mkdir $IMG_DIR

scanadf --resolution=200 --start-count=1 --end-count=1
convert image-0001 -crop 495x694+0+0 photo1.jpg
With the Gedit window open delete everything on the page and copy and paste all
the green text above.
Save file as '' (without the quotes).

My changes include the following:
Shorter folder name
One standard image size instead of three diffrent ones
Different output destination
Resolution bumped up to 200 instead of 150 
Here is what the '495x694+0+0' line means:
    • 495 pixels wide 
    • 694 pixels tall
    • +0 pixels to skip from top
    • +0 pixels to skip from left side

Put the file in a place where you can remember it.
I spent about 30 minutes getting the pixel count just right for a standard baseball 
I tried using Gimp to get the pixel count but I had a tough go of it from jerky mouse 
action. So I just did about 20 scans and used a Loupe lens to proof the card to the 
scanned image.
Plus, my mom was here so she helped out since she was a proofreader for all the 
Jack Daniels and other liquor labels before they were printed. She did it for 30 years.
Next time you see Jack somewhere, remember, somebody made sure you saw that 
label real clear(or not so clear, after a bit)! 
I used a 1990 Topps card as a guide because of the border dots on those cards. 
Just being able to count the rows and compare them was a big help. 

See what I mean by dots!

Step 6:

In Ubuntu 12.04 go to top panel and click on the gear on the right. Then go to
System Settings>Keyboard(under the Hardware section)>Shortcuts Tab>Custom

Click the '+' button.
Here's a picture of the input box:
Name: Whatever you want(I put Card Scan)

Command: This is the path to your file. If you saved it to your home 
folder you would put '/home/username/' (Without the quotes and insert 
your name for 'username'). 
 Hit Apply and click on your new shortcut and hit the sequence of keys you want to 
use as the shortcut. As you see above, I used Ctrl+Backslash, as it was easy to hit.

Now close the settings window and give your shortcut a try.

This only works from the top right of your scanner. That means your card needs to 
be in the top right corner of where your scanner starts scanning.

Now for me, it cuts off a pixel or two of the top and left side of the card since it 
doesn't read out that far on the glass. But you need to have a set spot to put each 
card so this is a minor issue that is hard to spot anyways.

If you need help just comment.

All credit for original script goes to Marwan.

Hope I helped somebody out there and thanks for reading!

No comments:

Post a Comment

Thanks for commenting and reading. more free stuff on Listia