0

I'm trying to create an action that makes the width of the canvas equal to its height.

I tried using cut and paste and tabbing between them, but this only works on the first picture.

Any I try after, just resize to the height of the original recording.

please help

i must do 350 a week, various size images, needing to be a perfect square.

I was going to create 2 actions, one if the height was larger and one if the width was larger, i need the square to be based on the larger of width and height

thanks corey

  • Can you provide some more information about the source sizes and desired destination size? Are they consistent? It’s probably possible to do what you’re after with a single action. – Marc Edwards Apr 16 '17 at 9:52
1

This might work for you, and this will work on both landscape and portrait images, cropping a 1.1 ratio square to your largest width or height.

If you record these steps below it will give you the result you need.

  1. Duplicate current layer
  2. Rotate current layer 90 degrees
  3. Reveal all
  4. Delete current layer

enter image description here

Then you can add a Save action if you need to save it, or load this action into File > Scripts > Image Processor for images in multiple locations.

Download the action here: Stack Exchange - Square Crop.atn

1

You can use Photoshop Scripting to do this.

Save the following into a new file called squarecrop.js in some folder that is convenient for you. You'll want to leave it there so you can use it in the future. This will find whether the image is wider or taller and crop accordingly, keeping the center of the image. It does not check to see if the image is already square, I assume you won't be doing anything to those images.

#target photoshop
// get current active document
doc = app.activeDocument; 

// create variables
var bounds, left, top, right, bottom;

if(doc.height > doc.width) {
    // document is taller, need to crop to square based on width
    left = 0;
    top = (doc.height-doc.width)/2;
    right = doc.width;
    bottom = top + doc.width;
} else {
    // document is wider, need to crop to square based on height
    left = (doc.width-doc.height)/2;
    top = 0;
    right = left + doc.height;
    bottom = doc.height;
}

// set bounds for cropping
bounds = [left, top, right, bottom];
doc.crop(bounds);

//~~~ SAVES OVER ORIGINAL FILE AND CLOSES ~~~
doc.close(SaveOptions.SAVECHANGES);
//alternately, you can use doc.save(); to save without closing.

Note that, as the comment at the end says, this will OVERWRITE the original of the file you run it on. Make sure you're planning for that to happen.

Next! Open up a file. Create a new action, call it whatever you want. Start recording. Go to File > Scripts > Browse and choose squarecrop.js wherever you put it. The document you have open should crop, save, and close automatically. Stop recording the action.

For more info, see the photoshop scripting documentation: http://wwwimages.adobe.com/content/dam/Adobe/en/devnet/photoshop/pdfs/photoshop-cc-javascript-ref-2015.pdf

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.