Skip to main content
Participating Frequently
March 27, 2024
Answered

Help needed please to write a script and action

  • March 27, 2024
  • 3 replies
  • 742 views

Hi Adobe Community, can i ask for some help and advice please with regards to updating files in bulk to do the following ....  i need to:

 

grab files one by one from a specified folder

trim image

make shorter canvas dimension = to longer canvas measurement (ie. square canvas)

resize image to 800 x 800 (only if size > 800 x 800)

Export > Save for Web with Quality Low to a specified folder

Close the image tab

Then move onto next image

  

This topic has been closed for replies.
Correct answer Stephen Marsh

All of this should be possible with an action and batch command.


Are the source images on a transparent background for the trim command?

 

After trimming, duplicate the image and rotate 90 degrees and reveal all to get a square canvas, then delete the rotated layer.

 

Or alternatively to the rotated layer trick, just use fit image and then canvas size, as mentioned here:


https://community.adobe.com/t5/photoshop-ecosystem-discussions/batch-resize-export/m-p/14513463#M795849

 

Save for web doesn't play nice with batch actions, you would need to use save as.

 

Otherwise a script would be required for save for web to use a variable file name.

 

Can you post a screenshot of the layers panel for one of the images? Are all files consistent in their layer structure?

3 replies

Stephen Marsh
Adobe Expert
March 27, 2024

File > Automate > Fit Image to 800 x 800 pixels has a checkbox option to resize images to the longest edge without enlarging.

 

Then resize the canvas to 800 x 800 pixels.

 

No need for the rotated layer trick (which is for transparent backgrounds).

Stephen Marsh
Adobe Expert
March 27, 2024

The Batch command has an option to override recorded Save command paths and names. This doesn't work with Export > Save for Web.  If running a Batch with a recorded Export command it will overwrite each file in the batch with the same name.... At least that's how I remember it working.

 

EDIT: I just tested, perhaps I remembered it wrong then...

Brainiac
March 27, 2024

Save for Web in an action will export with the existing filename. I use this daily.

Stephen Marsh
Adobe Expert
March 27, 2024

With the batch command?

 

EDIT: I just tested, perhaps I remembered it wrong then...

Stephen Marsh
Stephen MarshCorrect answer
Adobe Expert
March 27, 2024

All of this should be possible with an action and batch command.


Are the source images on a transparent background for the trim command?

 

After trimming, duplicate the image and rotate 90 degrees and reveal all to get a square canvas, then delete the rotated layer.

 

Or alternatively to the rotated layer trick, just use fit image and then canvas size, as mentioned here:


https://community.adobe.com/t5/photoshop-ecosystem-discussions/batch-resize-export/m-p/14513463#M795849

 

Save for web doesn't play nice with batch actions, you would need to use save as.

 

Otherwise a script would be required for save for web to use a variable file name.

 

Can you post a screenshot of the layers panel for one of the images? Are all files consistent in their layer structure?

c.pfaffenbichler
Adobe Expert
March 27, 2024

@Stephen Marsh , a while back I had some issues with Save for Web in Scripts (I think it was png in that case) but didn’t do in-depth trouble-shooting and just worked around it. 

Have you utilized Save for Web in Scripts recently? 

Brainiac
March 27, 2024

My workflow depends heavily on Save for Web but I've found that it works better as an Action. I recommend saving an SfW action and calling that from a script.