Mobile app version of vmapp.org
Login or Join
Pierce403

: I'm trying to automatically crop my canvas size to a square 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

@Pierce403

Posted in: #AdobePhotoshop #Canvas

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

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Pierce403

2 Comments

Sorted by latest first Latest Oldest Best

 

@Sherry646

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: wwwimages.adobe.com/content/dam/Adobe/en/devnet/photoshop/pdfs/photoshop-cc-javascript-ref-2015.pdf

10% popularity Vote Up Vote Down


 

@Kevin459

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.


Duplicate current layer
Rotate current layer 90 degrees
Reveal all
Delete current layer




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

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme