Photoshop: Automatically superimpose a lot of photos on a white square of 500x500px

  • 1
  • Question
  • Updated 7 years ago
  • Answered
  • (Edited)
Hi. I have a bunch of photos with sizes like e.g. 480x500, 500x360, 500x500, etc. So, all of them are limited to 500pixels but have different sizes/shapes, meaning one or both dimensions (length and width are 500). I want to make them all square 500x500 by adding white where it's necessary if they are reclangle . One way to do this would be to overlap/superpose each photo on a 500x500 white square but I have to do this for hundreds of photos.
Is there any way to define an "action" in order to perform this operation automatically?
Thanks.
Photo of LaurentiuP

LaurentiuP

  • 7 Posts
  • 0 Reply Likes

Posted 7 years ago

  • 1
Photo of Howard Pinsky

Howard Pinsky, Champion

  • 117 Posts
  • 28 Reply Likes
I'm wondering if this would work.

Make 2 actions: The first action would be for images that are longer rather than wider.

- Change the image size. Set the width to 500px.
- Change the Canvas size. Set the height to 500px, making sure that White is your background color.

This will add a white border at the top of the image, leaving you with a 500x500 image.

The second action will be the same, but opposite.

Then, I would suggest creating a Droplet for each set of Actions. Sort your photos into two folders. (Portrait/Landscape). Use the Droplets accordingly.

I hope that makes sense.
Photo of LaurentiuP

LaurentiuP

  • 7 Posts
  • 0 Reply Likes
Thanks Howard
I had no idea about the Resize canvas option and this does exactly what I need.
The only problem is that I don't know how to automate this task for hundreds of photos. I tried with Droplets (which I also didn't know about) but it didn't work even though I followed the instruction from the help step by step. I get an error saying "Adobe Photoshop has stopped working"..
I also tried with actions (which I know how to use) but I guess they are not good to use for this task (don't know why...)

So a little bit more help would be appreciated.
Thanks
Photo of Howard Pinsky

Howard Pinsky, Champion

  • 117 Posts
  • 28 Reply Likes
Here's a tutorial I made back in 2008. It might be a bit outdated, but it should help a bit. If you have any further questions, let me know and I'll try to answer them when I get home today.

Http://www.YouTube.com/watch?y=OSzgAu_VptU
Photo of Howard Pinsky

Howard Pinsky, Champion

  • 117 Posts
  • 28 Reply Likes
Oops. That link was broken.

www.YouTube.com/watch?v=OSzgAu_VptU
Photo of LaurentiuP

LaurentiuP

  • 7 Posts
  • 0 Reply Likes
It worked, Howard :)
I watched your tutorial and understood about the droplets but still something was wrong and I got an error when I was trying to use the droplet.
But I did it by using actions.
I did what you suggested at first, split the pictures into 2 groups (more wider than taller and more taller than wider), then I recorded 2 actions for the 2 groups and applied them.

It worked.

I still am amazed how people can help one another without any interest whatsoever. It's so nice of you and the others for trying to help!!

Thank you very very much!
Photo of Howard Pinsky

Howard Pinsky, Champion

  • 117 Posts
  • 28 Reply Likes
You're welcome, Laurentiu! That's what we're here for. The tutorial is almost 3 years old. I think I might have to update it. :)
Photo of Paul Riggott

Paul Riggott

  • 346 Posts
  • 131 Reply Likes
The easiest way is to use a script as part of the action.
The following code will make the current document 500x500 pixels.

#target Photoshop
function main(){
var startRulerUnits = preferences.rulerUnits;
preferences.rulerUnits = Units.PIXELS;
var FillColour = new SolidColor;
FillColour.rgb.hexValue = 'ffffff';
app.backgroundColor= FillColour;
app.activeDocument.resizeCanvas(500, 500, AnchorPosition.MIDDLECENTER);
app.preferences.rulerUnits = startRulerUnits;
};
main();
Photo of LaurentiuP

LaurentiuP

  • 7 Posts
  • 0 Reply Likes
Thank you, Paul, but I'm not a programmer and I don't know how/where to use this script. Could you give more details?
Photo of Paul Riggott

Paul Riggott

  • 346 Posts
  • 131 Reply Likes
Copy the code into a plain text editor or better still into ExtendScript Toolkit (this is installed at the same time as Photoshop)

This utility can be found in the relevant folder:-
PC: C:\Program Files\Adobe\Adobe Utilities
MAC: /Applications/Utilities/Adobe Utilities

The script needs to be saved into:-
PC: C:\Program Files\Adobe\Adobe Photoshop CS#\Presets\Scripts
NB: Vista and Windows 7 you will have to save it elsewhere and copy it to this folder due to permissions.

MAC: /Applications/Adobe Photoshop CS#/ Presets/Scripts

# being the Photoshop CS version.

If Photoshop was open close and re-start Photoshop so that it can pick up the new script.

To Use:
The script can be a part of an Action and to call the script can be done in a couple of ways:-
File - Scripts - select the script ( this will run the script)
or
In your action, select "Insert Menu Item" from the action palette fly-out menu, then File - Scripts - select the script
This won't run the script at this time but will run the script when the action is run.

Once you have your action it can the be batched.
Photo of LaurentiuP

LaurentiuP

  • 7 Posts
  • 0 Reply Likes
Thanks for the explanations.
I did what you said but when I try to use the script I get an error reading:
"Error 1302: No such element
Line: 8
-> app.activeDocument.resizeCanvas(500,500,AnchorPosition.MIDDLECENTER);

I already found a solution to deal with this task but I am interested in working with scripts because there was another time in the past when I needed a script and I'm sure there will be other times in the future.

Thanks a lot
Photo of Paul Riggott

Paul Riggott

  • 346 Posts
  • 131 Reply Likes
You would get that error if you were using the first method of recording the action if you didn't have a document open.
Photo of LaurentiuP

LaurentiuP

  • 7 Posts
  • 0 Reply Likes
Now it worked with script too.
Thanks a million, Paul!
Photo of Jeffrey Tranberry

Jeffrey Tranberry, Sr. Product Manager, Digital Imaging

  • 13977 Posts
  • 1666 Reply Likes
Won't the Automate>Fit Image... command work for this? It handles images of different dimensions and aspect rations to fit them within a fixed bounds.

How to Use Fit Image in Photoshop
Photo of Paul Riggott

Paul Riggott

  • 346 Posts
  • 131 Reply Likes
Sorry but this won't work, it has to be an increase of the canvas to reach 500 x 500 pixels Fit Image can't do this.
Photo of Zeno Bokor

Zeno Bokor, Champion

  • 6 Posts
  • 1 Reply Like
Fit Image won't do anything in this case because his images already fit in a 500x500 pixel box. He doesn't want to fit the images in a 500x500 pixel box, he wants the images to be exactly 500x500 pixels
Photo of LaurentiuP

LaurentiuP

  • 7 Posts
  • 0 Reply Likes
Indeed, Jeffrey, my images already fit 500x500 (some are exactly with this dimensions, others have the width 500 and the height smaller or vice versa).
I guess the command "Canvas Size" recommended by Howard helps to reach my goal for each picture but I don't know how to automate it for hundreds of photos. I tried to define an Action (I am familiar with them) but somehow it doesn't work...