Copy link to clipboard
Copied
PS has a nice command that will automatically crop and straighten pics that have been scanned. I've tried to run this command on my single pics and it works fine, except that I also get two additional crops/pics of stray hairs on the black background. I've also tried to make an action that I can turn into a batch or droplet and run on all the pics. I've not had much success. I'll end up with pics of stray hairs and not the card. I then have to go and manually delete the stray pics. Too much work.
Is there any way I can automate the process of cropping, straightening the pics then saving then new version?
Thanks
1 Correct answer
I think this was the script....
#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 = doc.name.slice(0
...
Explore related tutorials & articles
Copy link to clipboard
Copied
Have a look here..
http://www.adobeforums.com/webx/.59b7368d/5
Copy link to clipboard
Copied
Hi Paul, looking for the article from the link you posted (http://www.adobeforums.com/webx/.59b7368d/5)
but it takes me to the forum home page (http://forums.adobe.com/index.jspa)
Could you give me some keywords or the topic so I can find it?
Copy link to clipboard
Copied
I think this was the script....
#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 = doc.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;
};
Copy link to clipboard
Copied
Thank you, thank you, thank you.
You just saved me about 90 minutes worth of work by reposting this script. I followed your directions and I'm now watching Photoshop fly through a batch crop and straighten process for about 60 "gang scanned" images.
I really appreciate the help.
Cheers,
AJ
Copy link to clipboard
Copied
I do not know why this append is here in an old thread on batch crop and straightening images for baseball cards. If this append has anything to do with something like a composit thing a baseball card, mag cover etc. An other way to address the problem is to batch populate a Photo Collage Template that will auto size and place in images into a template and leave the populated collage as a PSD file so that it can be tweaked. ie Straighten image add anotation change position etc. My Photoshop Photo Collage Toolkit is designed to do just that. In fact is comes with a sample Baseball Template and Mag Cover template. The sample Basball Template has many groups and hidden layers that let you change things like Logos, Frame, Field position etc. Example: Babe Ruth Card.jpg and JJMackTime.jpg
Documentation and download: Free Photoshop Photo Collage and Mockup Toolkit
Copy link to clipboard
Copied
The second issue is what the heck do I do with the code? I'm not a programmer or even a good PS user so the code is meaningless to me. Do I copy and paste it somewhere??
Copy link to clipboard
Copied
All it means is that it will automate doing a folder of documents.
All the new extracted documents are save in a folder called "Edited" off the selected folder.
Photoshop JavaScripts are saved useing a text editor or better still Photoshop editing environment "Adobe ExtendScript Toolkit" this get installed at the same time as Photoshop. Copy the code and paste it into a new "ExtendScript Toolkit" document the save it to the relevant folder.
PS7 and PSCS are saved with an "js" extension and PS2/3/4 are saved with a "jsx" extension.
The normal place to save the scripts is:
PC:- C:/Program Files/Adobe/Adobe Photoshop CS#/Presets/Scripts/
Mac:- [hard drive]/Applications/Adobe Photoshop CS#/Presets/Scripts/
Allthough they can be saved anywhere you like.
To run a script:
File - Scripts (select script) (if placed in above folders) or
File - Scripts - Browse (to where ever you saved the script.)
Copy link to clipboard
Copied
I really appreciate your help.
Copy link to clipboard
Copied
C:\Program Files\Adobe\Adobe Utilities
CS3 and CS4 there should be shortcuts existing under Start - Programs
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Applications - Utilities - Adobe Utilities - "ExtendScript Toolkit 2"
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I figured it out right before you posted. The script works quite well! I just have to delete the un-necessary pics that I get. The script is taking each photo and spitting out three copies, one with the crop I need and two smaller ones with cropped shots of hair that was on my black background. I guess when I shoot the next batch of pics, I'll use a clean, white background instead.
thanks again for all your help!!!
Copy link to clipboard
Copied
Script on GitHub. Save script in text editor as .jsx file.
Do not place .jsx file in folder with "RUN" scanned photos.
Do NOT place "OUTPUT" folder in folder with RUN scanned photos.
Open Photoshop
Go to FILE / SCRIPTS / BROWSE
Select the .jsx file.
You will see popup boxes with instructions in small print at op of box instructing you to make selections.
Wait and watch for the magic to happen.
Copy link to clipboard
Copied
Perfect.
Only nitpick - the recursion just document that the output folder should not be a sub-folder of the source - otherwise you get in a recursive loop.
My project went from weeks to days with this i think.
Truly, truly appreciated.

