Skip to main content
goldenape
Participating Frequently
November 20, 2020
Answered

Script for: Batch Import, Place, Crop Remainder of Canvas, Save As

  • November 20, 2020
  • 3 replies
  • 1006 views

Hello, I am looking to do the following:

 

1. Import a batch of photos

2. Place said photos (one by one) onto a 300x300 canvas, centered

3. Crop remainder of the canvas

  • so if portrait orientation, crop Left/Right of remaining canvas pixels
  • if landscape orientation, crop Top/Bottom of remaining canvas pixels

4. Save image to a designated folder

5. Repeat for each image in a batch import.

 

Thanks in advance.

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

Place, because pic dimensions vary.

 

All files flattened.

 

Saving to JPEG, high quality.

 

 


That's what FIle > Automate > Fit Image is for. Just record an action using the Fit Image command and enter 300px for both the width and depth of the resized image. This will be recorded. When batch played using Batch or Image Processor running the action, the longest width or depth edge will be resized to 300px and the other shorter edge will be proportionally resized smaller.

 

With reflection, I don't think that there is any need to record the trim command.

3 replies

Bojan Živković11378569
Community Expert
Community Expert
November 20, 2020

What are dimensions of your images that you want to place? Always the same or not? Images to be placed exceed canvas dimensions or not? Are you aware of Photoshop features and optional configurations in Preferences regarding Place commands? Things can be done in a few different ways, by the way. I am asking you to check your awarness for case to record action(s) which are probably possible but task is not that straight forward.

goldenape
goldenapeAuthor
Participating Frequently
November 20, 2020

Dimensions vary. But all have at least one side bigger than 300px.

 

Images exceed canvas almost always.

 

 

Bojan Živković11378569
Community Expert
Community Expert
November 20, 2020

Then you must run Fit Image in this process. My idea to record action is following with guess that you have flatt images which you are trying to place.

 

Record action and run it using Image Processor Pro, for example:

  • Fit Image into 300x300px.
  • Select All > Copy
  • Switch to previous tab (while recording action ensure that previous tab contains Image or canvas 300x300px)
  • Paste copied content
  • Use Trim from Image menu to trim top left pixel color which should be in any case white or canvas visible.
  • Select All > Copy
  • Undo last operation of Trim
  • Delete top layer which contains pasted image
  • Switch to next tab
  • Paste copied content
  • Use Image > Reveal All

 

Note: I am not checking action while writing, I am writing steps from my head so mistake are possible.

 

Update: I have overlooked some things in this request. Use @Stephen Marsh suggestion and ignore my complex action recording which is not necessary.

Stephen Marsh
Community Expert
Community Expert
November 20, 2020

You should be able to do this with an action using Fit Image and Trim commands (perhaps adding a conditional action if you have a mix of flattened and layered images), then run the action via Batch, Image Processor or Image Processor Pro. 

goldenape
goldenapeAuthor
Participating Frequently
November 20, 2020

Thanks for your help. Do you mind walking this dummy through it step by step?

I've been trying to implement your answer for about 15 min now and seem to be stuck.

Stephen Marsh
Community Expert
Community Expert
November 20, 2020

Why place?

 

Are all files flattened?

 

What file format are you saving to?

JJMack
Community Expert
Community Expert
November 20, 2020

Free Download  The Image file scans be Placed into your template's 300x300px image area space. Any excess image area will be masked off. the result will look like a centered 1:1 Aspect Ratio crop.

JJMack