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

Help needed please to write a script and action

Community Beginner ,
Mar 27, 2024 Mar 27, 2024

Copy link to clipboard

Copied

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

  

TOPICS
Actions and scripting

Views

330

Translate

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

correct answers 1 Correct answer

Community Expert , Mar 27, 2024 Mar 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

...

Votes

Translate

Translate
Adobe
Community Expert ,
Mar 27, 2024 Mar 27, 2024

Copy link to clipboard

Copied

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#M795...

 

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?

Votes

Translate

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 Beginner ,
Mar 27, 2024 Mar 27, 2024

Copy link to clipboard

Copied

that's a great trick to get the square canvas thank you.  will give it a go, i'm fine doing actions but no idea with script writing.  Yes all files are generally jpegs so should be fine.  I'm still not sure with the resizing though.... our optimum size for the website is 800x800...   so only want to resize the image if it is larger than 800 x800.  If it is already smaller than i don't want to resize as will make bigger and distort the quality.  I know what you mean with save 4 web being problematic so will use save as because with the rotation it may cause issues if the layer structure is then changed.  Thank you so much for your reply.

Votes

Translate

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 ,
Mar 27, 2024 Mar 27, 2024

Copy link to clipboard

Copied

quote

Yes all files are generally jpegs so should be fine.


By @Ritchie36355631q2t1

 

So the trim command would then need to be based on the top left and or bottom right pixel colour as JPEG doesn't support transparency.

 

Due to the lossy nature of JPEG compression a pure white background may not remain that way, so when you re-open the JPEG file the trim command may or may not work as expected.

 

Can you provide some of the JPEG files for testing?

 

Votes

Translate

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 Beginner ,
Mar 28, 2024 Mar 28, 2024

Copy link to clipboard

Copied

The trim does he generally work fine based on top left as you say. I think its all sorted now thank you so much



Sent from my Galaxy

Votes

Translate

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 ,
Mar 28, 2024 Mar 28, 2024

Copy link to clipboard

Copied

LATEST
quote
The trim does he generally work fine based on top left as you say. I think its all sorted now thank you so muchSent from my Galaxy
By @Ritchie36355631q2t1

 

 

If all is sorted, please mark one or more replies that helped you to resolve the issue as a correct anwser.

Votes

Translate

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 ,
Mar 27, 2024 Mar 27, 2024

Copy link to clipboard

Copied

@Stephen_A_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? 

Votes

Translate

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
LEGEND ,
Mar 27, 2024 Mar 27, 2024

Copy link to clipboard

Copied

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.

Votes

Translate

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 Beginner ,
Mar 27, 2024 Mar 27, 2024

Copy link to clipboard

Copied

thank you very much, i will certainly give that a try

Votes

Translate

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 Beginner ,
Mar 27, 2024 Mar 27, 2024

Copy link to clipboard

Copied

i've never used save for web in scripts only in actions.....   generally speaking it is fine for but only troublesome where layers are in.  Many thanks

Votes

Translate

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
LEGEND ,
Mar 27, 2024 Mar 27, 2024

Copy link to clipboard

Copied

I export out complex images with layers on a production system (product photography) and SfW is the most reliable for my needs.

Votes

Translate

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 Beginner ,
Mar 27, 2024 Mar 27, 2024

Copy link to clipboard

Copied

I think i will be fine without the need for this as my images always start as one layer pretty much, many thanks for your reply

Votes

Translate

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 Beginner ,
Mar 27, 2024 Mar 27, 2024

Copy link to clipboard

Copied

this works a treat thank you so much, my only concern was that i'm potentially resizing images smaller than 800x800 to this size but on first run had some of these and the quality looks fine for the website.

Votes

Translate

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 ,
Mar 27, 2024 Mar 27, 2024

Copy link to clipboard

Copied

quote

@Stephen_A_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? 


By @c.pfaffenbichler

 

 

I vaguely remember a case where a GUI selection was being honoured over the script parameters... But I can't remember exactly.

Votes

Translate

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 ,
Mar 27, 2024 Mar 27, 2024

Copy link to clipboard

Copied

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...

Votes

Translate

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
LEGEND ,
Mar 27, 2024 Mar 27, 2024

Copy link to clipboard

Copied

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

Votes

Translate

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 ,
Mar 27, 2024 Mar 27, 2024

Copy link to clipboard

Copied

With the batch command?

 

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

Votes

Translate

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 ,
Mar 27, 2024 Mar 27, 2024

Copy link to clipboard

Copied

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).

Votes

Translate

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