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

Batch Image Resizing with Recognition of Portrait or Landscape

Explorer ,
Jul 01, 2017 Jul 01, 2017

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

TOPICS
Actions and scripting
4.9K
Translate
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
Guide ,
Jul 01, 2017 Jul 01, 2017

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

Translate
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
Explorer ,
Jul 01, 2017 Jul 01, 2017

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.

Translate
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
Guide ,
Jul 01, 2017 Jul 01, 2017

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.

Translate
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 ,
Jul 01, 2017 Jul 01, 2017

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

Example
Download

Warning Adobe added a bug in Photoshop Scripting in CC 2015.5 and CC 2017 that bites my run twice scripts......

JJMack
Translate
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
New Here ,
Aug 02, 2023 Aug 02, 2023

Hi!

Did you solve it? I need the same thing - I want the shortest length of my images to be 1024px. 

Translate
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 ,
Aug 02, 2023 Aug 02, 2023
LATEST

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;
};
Translate
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