I use Actions in Photoshop (currently using CS4) all the time, but have never delved into the scripting capabilities, so please forgive me if these questions are obvious.
The basic description of my project is simply creating web images in jpg format, from our library of high-res print images.
We're going to have one folder with a copy of all the images we need to convert. File types range from EPS, TIF, PSD and JPG.
The challenges (to me) are:
1. these images vary in orientation of being tall or wide; I need the greater of the dimensions, whether it be height or width, to be 400 pixels; and then I need canvas added to the other dimension to make the image a perfect 400 x 400 square. I don't know how to, or if I can, make PS choose the greater of the dimensions, to set it to 400 px.
2. some of these images have clipping paths; i need to use those paths to erase the background in the photos; the names of these clipping paths are not the same in every image.
So, the basic flow of the script would be open the file; set the max dimension to 400 px; add white canvas to fill the other dimension and make that also 400px; use the image's clipping path if it has one to erase the image's background; save for web as jpg, appending "-400" to the end of filename (but before the ".jpg"); set size to 115 and save for web, appending "-115" to the name; set size to 80 and save for web, appending "-80" to the name.
You can use Image Processor (Scripts:Image Processor) to resize to fit in a specific size. It will resize to fit inside those dimensions. You can save out as a PSD, Jpeg and/or TIFF. You can also specify an action to run, create an action to use the clipping path as a mask on your layer. You might need a few extra steps to make sure the action works with all of your images (e.g. merge visible before masking in case there are multiple layers).
If the image processor doesn't get you all of the way to where you want, or the output isn't what you need (e.g. gif, png), you can set the output to PSD, and run another batch action on the resulting files to finish the job.
Paul.... That is great stuff. Thank you so much!
I just ran it on a folder to test it out, and it works great, although I noticed a few files had oddities in their names. Here is an example:
That's the filename, and it is missing the .jpg extension. Perhaps the original filename was too long? The same thing happens on the other 2 size versions of this image.
Did you create this using the Image Processor script as the base? The reason I ask is because I had tried the Image Processor a little bit before you replied, and although it wasn't the complete solution I needed, it did have two different things that would be great to have in your script. So basically, if it'd be easy to copy and paste those things from the Image Processor script into yours, than I'd ask.... but if it's complicated, I wouldn't trouble you, because you've already been kind enough to write me a version of your script.
The two things are:
the ability to include sub-folders (i have 100+ sub-folders)
and the way Image Processor creates a folder called JPEG in every folder/subfolder, for the processed images.
Your script is already saving me enough time, that I can use it as is. but if it's an easy copy/paste to add those 2 Image Processor functions, I'd be thrilled to have them.
The problem with filename could be a setting within Photoshop, try this...
Open a document in Photoshop then ..
File - Save for Web & Devices
at the right hand side of the preset dropdown box there is a downarrow click this and select edit output settings.
Keep clicking next until you see "Filename Compatibility" and untick "Mac OS 9"
No it isn't based on "Image Processor" it was based on my Save For Web CS4.
The script will need to have a fairly major change to add those options, so I will have a look at it tomorrow Sean.
I was asked to add a size to the script. I cracked it open myself and changed this section:
app.activeDocument.resizeCanvas(400, 400, AnchorPosition.MIDDLECENTER);
if(win.panel0.Progressive.value) Progressive = 4;
doc.resizeImage(undefined, 200, undefined, ResampleMethod.BICUBICSMOOTHER);
ext = "-200.jpg";
doc.resizeImage(undefined, 115, undefined, ResampleMethod.BICUBICSMOOTHER);
ext = "-115.jpg";
doc.resizeImage(undefined, 80, undefined, ResampleMethod.BICUBICSMOOTHER);
ext = "-80.jpg";
All I did was copy the lines for the 115 size, and change them to 200. And I changed the "Progressive =" from 3 to 4, which was just a guess.
I tested it out and it worked fine.
Europe, Middle East and Africa