Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
1

How to batch resize multiple images into squares?

Guest
Dec 01, 2016 Dec 01, 2016

Copy link to clipboard

Copied

Hi!

So I have several hundred images that are of varying sizes from 600x1000 pixels to 4000x1000 pixels. So I want to make them all into square images. So far I have only figured out how to automate by recording actions changing the canvas size to a set amount, ie I change the 600x1000 to 1000x1000 which works but doesn't work for the 4000x1000 image. If I changed them all to 4000x4000 then the smaller images would be in to small of a square. Is there anyway to change the canvas size in a way that I don't have to specify the exact size and use a more fluid/relative method?

Hopefully this makes sense!

Views

3.7K
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Dec 01, 2016 Dec 01, 2016

Copy link to clipboard

Copied

Action are recorded Photoshop step. In Adobe added conditional action support a while back where an action cap play(call) other action in the action set the action  is in depending on some conditions.  Actions can test some document conditions and some layer conditions.  And that is all the logic action can muster on their own.  They  can not retrieve information like document  width and document height and use that that information to deal with size.   There few conditions the can test.

Photoshop has an additional automation feature Photoshop Scripting. Actions can use Scripts and Scripts can do Photoshop Actions.

Photoshop Scripts can use logic and can easily do what you want to do.  However scripting is programming you have to program Photoshop Scripts using a scripting language like JavaScript.

What you want to do is simple program.

If document width is greater than document height  canvas size width=document_width  height=document_width

else canvas size width=document_height height=document_height.

Square document canvas sized will not change.   Landscape and portrait document canvas sizes will change canvas will be added to make the document square.

Write that script. Record an action menu File>Scripts>ScriptName then batch that action.

.

JJMack

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 01, 2016 Dec 01, 2016

Copy link to clipboard

Copied

Thanks for the help! I am not fluent with scripting. Are any scripts already created that you know of? Or do I have to find someone to write the code?

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 01, 2016 Dec 01, 2016

Copy link to clipboard

Copied

If you want to automate process that require some logic it would be a good idea to learn a little about scripting Photoshop.   I have a programming background.  However I also have some disabilities.   I can not type and a do not know JavaScript.   But I'm also a featless hacker.  It would be nothing to hack that script for you.  However I'm not going to.  That is something you should learn to do. Start here Tutorials > Scripting Photoshop, Part 1 — An Introduction | Trevor Morris Photographics

Tutorials > Scripting Photoshop, Part 2 — A Practical Example | Trevor Morris Photographics

he has easy well commented sample you can learn from. It may sound scary programming but it is not actually hard.

Adobe Photoshop Scripts | Trevor Morris Photographics

Here is a video I made to show how one of my scripts work.  Hopefully it will give you an idea what you can do with Photoshop scripting. http://www.mouseprints.net/old/dpr/Populate911_720p.mp4

JJMack

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 01, 2016 Dec 01, 2016

Copy link to clipboard

Copied

LATEST

Did ​you take the bait? Did you bit? Did you look at any Photoshop scripts?

I wrote I would not write that simple script for and  I will not. you should. However I wrote a JavaScript Photoshop function some years ago the can be used to change a document Aspect Ratio to any aspect ration you may need it to have.  I have add additional comment for you to be more readable. It should be easy to follow.  I used it in a new script to do your job it a one liner

CanvasAR(1/1);

/* ==========================================================

// 20016  John J. McAssey (JJMack)

// ======================================================= */

// This script is supplied as is. It is provided as freeware. The author accepts no liability for any problems arising from its use.

/*

<javascriptresource>

<about>$$$/JavaScripts/CanvasAR/About=JJMack's Add Canvas to make Aspect Ratio.^r^rCopyright 2011 Mouseprints.^r^rScript utility.^rNOTE:Aspect Ratio Hard coded!</about>

</javascriptresource>

*/

#target photoshop

CanvasAR(1/1);                //Square Width and Height Equal 1/1

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function CanvasAR(AR) {

  if (documents.length < 1) { // if no document is open no can do

  alert("No Open Document!");

  return;

  };

  var originalRulerUnits = app.preferences.rulerUnits; // save user's ruler units

  app.preferences.rulerUnits = Units.PIXELS; // set to ruler units to pixels;

  var myDocument = app.activeDocument; // myDocument is the Photoshop active document

  var theRatio = myDocument.width/myDocument.height; // get myDocument aspect ratio

  // change canvas aspect ratio to AR

  if (theRatio > AR) { // if aspect ratio is wider then AR

  myDocument.resizeCanvas(myDocument.width, myDocument.width * 1/AR); // add canvas to the height make height 1/AR the width, width remains the same

  } else {

  if (theRatio < AR) { // if aspect ratio is narrower then AR

  myDocument.resizeCanvas(myDocument.height * AR, myDocument.height); //add canvas to the width make width AR * height, height remains the same

  }

  };

  // images that were AR were left that way images that were not AR had canvas added to make them have AR aspect ratio

  var theRatio = myDocument.width/myDocument.height; // the aspect ratio may have been been cganged

  if ( theRatio != AR) { alert("Ratio rounded to " +  theRatio + " should be close to " + AR);}

  app.preferences.rulerUnits = originalRulerUnits; // restore user's ruler units

};

Jive message up formatting you may be able to read the better

Capture.jpg

JJMack

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines