Using Crop Tool in an Action with varying size images

MC
Posted By
Martin_Coleman
Nov 24, 2008
Views
2956
Replies
16
Status
Closed
I have been googling this but can’t seem to work out a) if it’s possible and b) how to do it.

I have around 200 images of varying sizes that I want to get to a 75 px sq thumbnail. I can make an action resize and save for web but the crop tool is difficult. Could I somehow get the crop tool to start at the top left of each image and restrain the sq by the left side of the image to be cropped?

Thanks

Master Retouching Hair

Learn how to rescue details, remove flyaways, add volume, and enhance the definition of hair in any photo. We break down every tool and technique in Photoshop to get picture-perfect hair, every time.

JJ
John Joslin
Nov 24, 2008
Have you tried the Image Processor?
MC
Martin_Coleman
Nov 24, 2008
I did look at the Image Processor and can see there’s a "resize to fit" option but if I say put 75px by 75px in there and the original image isn’t a square, it’ll go wonky, I thought…

Thanks

Martin
JJ
John Joslin
Nov 24, 2008
Without running it to check I can’t be sure, but I think it will fit it to 75×75 without cropping or distortion.
JM
J_Maloney
Nov 24, 2008
Yes, but landscapes are 75 x 38 and portraits are 38 x 75. OP wants 150 x 75 and 75 x 150, ready for cropping down to 75 x 75 each. Fit image/processor uses the long dimension, but for cropping, OP wants to size to short.

If you make layer, and canvas size the doc with huge dimensions (maxx) then dup layer and rot 90, then intersect the layers’ transparencies, then make guides upper left at (this time) 75/75, then copy merged of small dimension selection (intersected trans) then align left and top, then transform, then transform again on the original layer.

But shouldn’t this be automated? Even web gal doesn’t do it. (??)
MC
Martin_Coleman
Nov 24, 2008
Whooo there J Maloney….

Slow down.

I am not sure what half of that means and the other half is pure guesswork.

What I want to end up with is a small thumb that has to be same size as all the other thumbs – 75 x 75. It would be straight forward if all my original images were Sq but they are random sizes.

I can automate by using an action for resize and save for web which is neat. I could also do it for images of the same ratio. What I can’t do is get the crop on different size/ratio images.

Thanks

Martin
DM
dave_milbut
Nov 24, 2008
there’s a "fit image" command, i think that may be what john was talking about. not at my ps machine, but a quick search of the help on that term should sort it out. with "fit image" you set the max size and let the program figure out what it needs to do to fit the image into your constraints while maintaining aspect ratio.
JM
J_Maloney
Nov 25, 2008
But fit image will give you thumbs with the long edge at 75 px. Good for showing the orientation of a photo, but no good for getting the largest version of the subject in the thumb as possible. I can’t figure out how to process images by the short edge…
JJ
John Joslin
Nov 25, 2008
If I now understand correctly, I think what the OP wants is impossible to automate without a script.
MC
Martin_Coleman
Nov 25, 2008
If that fit image thing works, I haven’t searched yet as I am not at my PS Pc either, it would be a good compromise to batch landscape and portrait images first or rotate one and then batch ’em

Martin
JM
J_Maloney
Nov 25, 2008
One way is to size them all to have a short dimension of 75. Then create an action that crops to selection and saves. Then go through your batch manually, and using the marquee tool at 75 x 75 fixed, pop it in where it looks nice and run the action to crop and save. I like this because I find it quicker than the crop tool which you still must drag out.

If you want to auto-crop your images, ie process them without looking at them, you can size them to the short dimension and crop using canvas size. It’s not like I process a lot of batch images, so I’m interested to know of a way to batch short-edge sizing, which I can’t figure out.

The long way I proposed was to canvas size the image to something much larger than your largest possible image (lets say 2000 x 2000). Then, make your image a layer by double clicking on it. Then duplicate the layer and rotate the duplicate by 90 degrees. Now select the intersection of the original layer and the new rotated layer’s transparency (load selection). You should now have a square selection that’s the size of the short dimension. You can now create a new layer and fill with white (or any color) using the square selection. Now, draw two guides in the top left that are exactly (shift key pressed while zoomed way in, if recording your action you’ll see the correct unit recorded) 75 pixels from the corner (top and left). Now select all and align to selection for both top and left (aligning the square layer to top left). Now, transform that layer (ctrl-t) and snap it to the guides (just drag up the bottom right corner to the guides, with snap on). If you now select the original image layer and "transform again", it will transform that layer to have a short dimension of 75. Now select that layer’s transparency and crop. Throw away the other two layers. Of course you’ve now got transparent pixels at the edge of your image. So ctrl-j, ctrl-e four times to kill off the transparency (make the pixels solid again).

Whew. I’d love to understand the best way to:

1) transform images to the short dimension

2) not have the edge of an image (rectangle) drop in opacity when transforming

Or script it, as JJ points out. My guess is that script it what, three lines?
JM
J_Maloney
Nov 25, 2008
Now, transform that layer (ctrl-t) and snap it to the guides (just drag up the bottom right corner to the guides, with snap on).

OK, so the above isn’t even actionable because the scaling is always based on percentage, even if you type px in the scale window. I’ll slink away now…
PR
Paul_R
Nov 25, 2008
Is this something like?
It does a fitimage on the short side and then crops using canvas size with anchor top left. It goes on to save the thumbnail in the same folder as the original with a suffix of -thumb (Save for web)

doc = app.activeDocument;

var saveFile = new File(decodeURI(activeDocument.fullName.fsName).slice(0,-4) +"-thumb.jpg");

var startRulerUnits = app.preferences.rulerUnits;

app.preferences.rulerUnits = Units.PIXELS;

fitImageShortSide(75);

app.activeDocument.resizeCanvas(75, 75, AnchorPosition.TOPLEFT);

SaveForWeb(saveFile,60);

app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

app.preferences.rulerUnits = startRulerUnits;

function fitImageShortSide(newImgSize) {

if (doc.width > doc.height) {

doc.resizeImage(undefined, newImgSize, undefined, ResampleMethod.BICUBICSHARPER);

}

if (doc.width < doc.height) {

doc.resizeImage(newImgSize, undefined, undefined, ResampleMethod.BICUBICSHARPER);

}

if (doc.width == doc.height) {

doc.resizeImage(newImgSize, newImgSize, undefined, ResampleMethod.BICUBICSHARPER);

}

}

function SaveForWeb(saveFile,jpegQuality) {

var sfwOptions = new ExportOptionsSaveForWeb();

sfwOptions.format = SaveDocumentType.JPEG;

sfwOptions.includeProfile = false;

sfwOptions.interlaced = 0;

sfwOptions.optimized = true;

sfwOptions.quality = jpegQuality;

app.activeDocument.exportDocument(saveFile, ExportType.SAVEFORWEB, sfwOptions);

}
JM
J_Maloney
Nov 25, 2008
Nice Paul. Thanks. 😀
MC
Martin_Coleman
Nov 28, 2008
Thank you so much Paul for putting this up but I am really sorry to say that I am not so sure what to do with it!

I guess it’s a script but that sort of thing is way beyond me. I’ll look at the help files and see if I can sort it out but if anyone can offer a few pointers – what’s the minimum I nee to know – it would be great.

I offer this as an explanation for the delay in coming back to say thanks rather than a request to save me the bother of learning new stuff!

Kind regards

Martin
PR
Paul_R
Nov 28, 2008
Depending on what version of Photoshop you have depends on what to do. PS7 needs to have the free scripting plug-in downloaded and installed first. PS7 and CS: the script needs to be saved with a text editor (Not word!) as fileName.js CS2/3/4 fileName.jsx
Normally the file would be saved in the following folder:- PC:- C:/Program Files/Adobe/Adobe Photoshop CS#/Presets/Scripts/ Mac:- [hard drive]/Applications/Adobe Photoshop CS#/Presets/Scripts/

Once you have saved the script, open one of you documents and record a new action that does:- File – Scripts – (select the new script) stop recording. This will have resized your document,saved it and closed the original. This new action can now be used in batch.
Hope it all makes sense Martin.
Paul.
DJ
David_J
Nov 29, 2008
A possible hint from a Matt Kloskowski web tutorial is to use the percentage measure for those parts of your action that apply to variable-size images.

How to Master Sharpening in Photoshop

Give your photos a professional finish with sharpening in Photoshop. Learn to enhance details, create contrast, and prepare your images for print, web, and social media.

Related Discussion Topics

Nice and short text about related topics in discussion sections