Copy link to clipboard
Copied
Hi everyone, new to scripting but do understand PS batch images and resize. What I am looking for is a script or action that will see the image as either portrait or landscape short or long and based on that resize the image to either 500 pixels short side if the image is portrait or 500 pixels long side if the image is landscape. Is this possible as so far I have not been able to get it to work via PS scripts or Mac Automator. Thanks in advance for the help.
Al
Copy link to clipboard
Copied
What you need to use is "Fit Image"
File - Automate - Fit Image
Video on how to use... Resize ANY Image with “Fit Image” in Photoshop CC - YouTube
Copy link to clipboard
Copied
Thanks but unfortunately that will not work as it always resizes the longest length. I need an action recognize the orientation of the image and then resize the shortest length to 500 pixels if the image is portrait and resize the longest length to 500 pixels if the image is landscape.
Copy link to clipboard
Copied
No it doesn't, the two figures that you supply it are max width and max height, it will then constain within those figures.
It is akin to make sure it will allways fit into a set size frame.
Also, Image Processor, Image Processor Pro and Picture Processor will all do this.
Copy link to clipboard
Copied
As SuperMerlin wrote Fit image retain an images Aspect Ratio. Portraits remain Portraits and Landscapes remain Landscapes. You set the max area the resize must fit within.
So Action can use the Adobe Fit Image Plugin script and resize image to fit.
Action can not use logic the are just step step step. However if You know some information about the document you dealing with that action can do steps base on that knowledge.
Here you know Fit image will constrain the resize to the document current aspect ratio. Little utility scripts like fit image can help actions be able to do things actions can not do on their own.
I put together a little package on crafting action from years of creating actions. In the package I include a doze of scripts I wrote to help action creates to use a little logic without having to write the script. Action are easy to record and edit when you have a good knowledge about Photoshop. Scripting requires programming knowledge not easy like recording steps.
Crafting Actions Package UPDATED Aug 10, 2014 Added Conditional Action steps to Action Palette Tips.
Contains
Warning Adobe added a bug in Photoshop Scripting in CC 2015.5 and CC 2017 that bites my run twice scripts......
Copy link to clipboard
Copied
Hi!
Did you solve it? I need the same thing - I want the shortest length of my images to be 1024px.
Copy link to clipboard
Copied
What is giving you problems with Scripting the task?
Edit:
// 2023, use it at your own risk;
if (app.documents.length > 0) {
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var myDocument = activeDocument;
var theWidth = myDocument.width;
var theHeight = myDocument.height;
var theScale = 1024 / Math.min(theWidth, theHeight) * 100;
myDocument.resizeImage (new UnitValue (theScale, "%"), new UnitValue (theScale, "%"), undefined, ResampleMethod.AUTOMATIC);
app.preferences.rulerUnits = originalRulerUnits;
};