I spent the last two days scanning photos from my family albums (about 900 photos). Scanning each photos individually will take lots of time, however not any further processing is needed. When you scan multiple images at once, you need to crop and straighten each photo from a single page you scanned.
With the scanner I had, I could fit 4 photos and scan them at once. And so I did. I chose it over scanning each photos individually because there are some tools to automagically crop photos from a group of scanned photos.
One thing that is very important in order to split photos is to make sure that there is some gap between the photos. Meaning, when you put the photos in the scanner, there should be a uniform background that separates each photos. They should not be overlapping, or touching each other. The splitter tools crop the photos based on where the background begins and ends, so this is important.Here are the tools that can help you to auto-split scanned images by batch cropping (and straightening) them. I have listed 6 tools here, two of which can be used on Linux, and four can be used on Windows (& some on mac).
Photoshop
To access this feature, you can go to File > Automate > Crop and Straighten Photos.
But, what if you have multiple scans, and you need to split them into single images like in my case?
Luckily, I found a PS script that does this for you.
#target Photoshop app.bringToFront; var inFolder = Folder.selectDialog("Please select folder to process"); if(inFolder != null){ var fileList = inFolder.getFiles(/.(jpg|tif|psd|)$/i); var outfolder = new Folder(decodeURI(inFolder) + "/Edited"); if (outfolder.exists == false) outfolder.create(); for(var a = 0 ;a < fileList.length; a++){ if(fileList[a] instanceof File){ var doc= open(fileList[a]); doc.flatten(); var docname = fileList[a].name.slice(0,-4); CropStraighten(); doc.close(SaveOptions.DONOTSAVECHANGES); var count = 1; while(app.documents.length){ var saveFile = new File(decodeURI(outfolder) + "/" + docname +"#"+ zeroPad(count,3) + ".jpg"); SaveJPEG(saveFile, 12); activeDocument.close(SaveOptions.DONOTSAVECHANGES) ; count++; } } } }; function CropStraighten() { executeAction( stringIDToTypeID('CropPhotosAuto0001'), undefined, DialogModes.NO ); }; function SaveJPEG(saveFile, jpegQuality){ jpgSaveOptions = new JPEGSaveOptions(); jpgSaveOptions.embedColorProfile = true; jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE; jpgSaveOptions.matte = MatteType.NONE; jpgSaveOptions.quality = jpegQuality; activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE); } function zeroPad(n, s) { n = n.toString(); while (n.length < s) n = '0' + n; return n; };https://forums.adobe.com/thread/290194
- Copy the above code and paste it onto a new file. Save the file as BatchCropAndStraighten.jsx (Take note of the file extension)
- Now, move the file to: C:/Program Files/Adobe/Adobe Photoshop CS#/Presets/Scripts/ if you are on PC, or [hard drive]/Applications/Adobe Photoshop CS#/Presets/Scripts/ if you are on mac.
- On Photoshop, Go to File > Scripts > BatchCropAndStraighten.
- Select the source folder (where you have stored the scanned photos).
- It will select each scanned image from the folder, split the photos and store them on edited folder inside the same source folder.
If the edited folder does not have split images, but the original scanned image, then you need to run BatchCropAndStraighten once again, but this time, choose the edited folder as your source folder. The new edited folder (inside the old edited folder) should contain split photos that have been cropped and straightened. I hope you got what I am saying.
Photoshop Elements
Go to Image > Divide Scanned Photos.
GIMP
Linux/Windows Users can use GIMP to split the photos. The instructions below are for Ubuntu users.
- First, install GIMP. (sudo apt-get install gimp)
- Follow the directions to compile deskew plugin for GIMP. (Note: In the end, the command to copy deskew to plugins folder should be : sudo cp deskew /usr/lib/gimp/2.0/plug-ins)
- Download DivideScannedImages.scm
- Copy it to /usr/share/gimp/2.0/scripts/ (sudo cp DivideScannedImages.scm /usr/share/gimp/2.0/scripts/)
- Open GIMP.
- Go to Filters -> Batch Tools -> Batch Divide Scanned Images…
- Select the Load From (source) and Save Directory (destination). The Abort Limit specifies maximum number of photos that are to be detected in a single scanned page. Play around with other settings.
- Click on OK.
Other Tools
-
AutoSplitter (Windows)
-
Mutlicrop Script (All)
You need to have ImageMagick Installed. But, you need to operate it via terminal/command prompt. So, google for the instructions on how to use it.
-
ScanSpeeder (Windows)
No related posts.
October 6, 2015 @ 11:08 pm
Thank you SO MUCH for this. I didn’t know how to use scripts and you both: 1) gave me the script I needed and 2) Explained how to use it. You just saved me hours and hours of work. <3
David
October 19, 2015 @ 12:25 pm
I’m glad you found it useful, David. :D
February 20, 2016 @ 9:22 pm
THANKS SO MUCH! I do this as a side job and you saved many hours of my life. Time is the most valuable think in life, so its quite a save. Thanks again
February 28, 2016 @ 2:07 pm
You’re welcome. Glad that it was helpful to you.
September 19, 2016 @ 8:27 am
Using the PS script again on the Edited-Folder gives an Error
Error 8000: Cannot open the file because the open options are incorrect
Line: 10
-> var doc= open(fileList[a]);
January 8, 2018 @ 2:50 am
Fix this line:
There’s a slash missing –
var fileList = inFolder.getFiles(/\.(jpg|tif|psd|)$/i);
November 19, 2016 @ 6:01 pm
Hi … I get this. Can’t proceed. Please help.
ggggg@Zorba-2:~/gimp-deskew-plugin$ ./autogen.sh –prefix=/usr
I am testing that you have the required versions of autoconf,
automake, glib-gettextize and intltoolize…
checking for autoconf >= 2.54 … 1
yes (version 2.69)
checking for automake >= 1.6 … Useless use of /d modifier in transliteration operator at /usr/local/share/automake-1.9/Automake/Wrap.pm line 60.
1
yes (version 1.9)
checking for glib-gettextize >= 2.0.0 … 1
yes (version 2.48.1)
checking for intltool >= 0.17 … 1
yes (version 0.40.5)
I am going to run ./configure with the following arguments:
–enable-maintainer-mode –prefix=/usr
WARNING: aclocal’s directory is /usr/local/share/aclocal, but…
no file /usr/local/share/aclocal/glib-gettext.m4
You may see fatal macro warnings below.
If these files are installed in /some/dir, set the ACLOCAL_FLAGS
environment variable to “-I /some/dir”, or install
/usr/local/share/aclocal/glib-gettext.m4.
aclocal:configure.in:77: warning: macro `AM_GLIB_GNU_GETTEXT’ not found in library
configure.in:76: warning: AM_NLS is m4_require’d but not m4_defun’d
/usr/local/share/aclocal/intltool.m4:27: IT_PROG_INTLTOOL is expanded from…
/usr/local/share/aclocal/intltool.m4:197: AC_PROG_INTLTOOL is expanded from…
configure.in:76: the top level
configure.in:76: warning: AM_NLS is m4_require’d but not m4_defun’d
aclocal.m4:17: IT_PROG_INTLTOOL is expanded from…
aclocal.m4:187: AC_PROG_INTLTOOL is expanded from…
configure.in:76: the top level
Useless use of /d modifier in transliteration operator at /usr/local/share/automake-1.9/Automake/Wrap.pm line 60.
configure.in:76: warning: AM_NLS is m4_require’d but not m4_defun’d
aclocal.m4:17: IT_PROG_INTLTOOL is expanded from…
aclocal.m4:187: AC_PROG_INTLTOOL is expanded from…
configure.in:76: the top level
configure.in:76: warning: AM_NLS is m4_require’d but not m4_defun’d
aclocal.m4:17: IT_PROG_INTLTOOL is expanded from…
aclocal.m4:187: AC_PROG_INTLTOOL is expanded from…
configure.in:76: the top level
configure.in:77: error: possibly undefined macro: AM_GLIB_GNU_GETTEXT
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
configure:5659: error: possibly undefined macro: AM_NLS
ggggg@Zorba-2:~/gimp-deskew-plugin$ make
make: *** No targets specified and no makefile found. Stop.
ggggg@Zorba-2:~/gimp-deskew-plugin$
January 23, 2017 @ 9:04 pm
Hey thanks for the excellent script. Used it a lot with CC 2015. Dosen’t seem to be working with CC 2017. Error message below. Any idea’s? Would love to get it working again. I get this error:
Error 25: Expected: ).
Line: 8
-> for(var a = 0 ;a < fileList.length; a++){
January 31, 2017 @ 3:52 pm
Hi Matt. Sorry for the delay. I didn’t make the script. I’m afraid I won’t be able to answer you.
But you should ask your question at the adobe forums. Here’s the link to the original thread: https://forums.adobe.com/thread/290194
If you do find an answer, please share it here so other’s will learn the workaround to it. Thank you!
February 2, 2017 @ 7:17 am
Hi Subigya, thanks for getting back to me. Actually it was me doing something stupid. The text editor I was using to create the file was removing the .jsx extension. Hence the reason it wasn’t working I believe. Anyway it was my rookie mistake. All working now. Thanks again
Matt
February 15, 2017 @ 7:16 pm
Its not a fault with the script, its the theme that this blog uses. Look into it and you’ll realize that it is not wrapping properly. Some characters have also been replaced with identical ones. Maybe the wrapper for the code was different when you first used it. Anyways, at the risk of repeating the solution, go here and use the code: https://forums.adobe.com/message/3705899#3705899 . I urge the author, Subigya Nepal, to either use a better code wrapper(instead of the inbuilt one) like Syntax Highlighter or provide a download link for a working jsx file.
February 16, 2017 @ 3:00 am
Hi Siddhant,
Thanks for the comment. You’re right, there’s no wrapping. However, indentation does not matter in jsx, so that was not the problem. What was problem however, was, the character entities as you pointed out. I’ve updated the code making the changes and it should now work.
I was using Crayon Syntax Highlighter but I left the language to default so I think it changed the greater and less than signs to character entities. I believe WP does not have any syntax highlighting by default(?). Anyway, thanks for letting me know! :)
February 16, 2017 @ 9:28 am
Hello again, I’ll restate – There was no ‘proper’ wrapping. Its fixed now. Indentation was never the problem but character entities, as you kindly pointed out.
I’m not buddy-buddies with the wordpress interface but I’ve gleaned that there are certain elements you can’t control there. Crayon is great, I’ve used it, but there are some things that are just out of reach with a plugin. Earlier, I was talking about the lightweight and customizable Syntax Highlighter by Alex Gorbatchev. With your own hosting space, it should be pretty straightforward to use. I have never had and have never heard issues with it, simply because its very simple to use; Simplistic to the core – even the way it works. Its just a wrapper. Forgive me for making this redundant comment just to clear my mind haha.
ps. I never mentioned anything about incorrect indentation but, oh well, sleep deprivation is known to make people see things. Catch some ZZzzs, my friend! :D
October 4, 2017 @ 1:08 am
Thank you so much! The script for Photoshop was exactly what I was looking for. Also the hint to perform the crop command again, if it just creates a copy of the scanned images, was very helpful. You saved me many hours of work! Awesome!!
October 4, 2017 @ 10:08 am
Glad to know its still useful. It’s 3 years old post. :)
November 25, 2018 @ 10:32 pm
Hi. Thanks for the PS script, but since I mostly expect .tiff, sometimes also .jpeg and .jp2, I add them to the extension list
inFolder.getFiles(/\.(jpeg|jpg|jp2|tiff|tif|psd|)$/i)
and later,
var docname = fileList[a].name
var x = docname.lastIndexOf(‘.’)
if (x > 0) docname = docname.substr(0, x);
Also, rather than calling function “zeroPad(count, 3)”, it could be simplified with: “(‘000’ + count).slice(-3)”
October 2, 2020 @ 10:08 pm
THANK YOU SO MUCH FOR THIS!!!!!!!