Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
392 views
in Technique[技术] by (71.8m points)

shell - Apple Automator / Scripting - Resize the same image to multiple sizes

I have an image and would like to resize it to give different sizes. Currently, I have 5 different automator scripts and I choose each one on the image file right click -> quick actions.

Ideally, I'd have one automator that would size them all to the different sizes OR I'd be able to run all the 5 scripts with one click.

Can't seem to figure out how to do either... any help?

edit: Here is one automator workflow which resizes the input finder image to 64px wide. I want to resize an image to 512, 256, 128, 64, 32 all in one flow rather than having to do each one after the other.

enter image description here

Thank you

question from:https://stackoverflow.com/questions/65557543/apple-automator-scripting-resize-the-same-image-to-multiple-sizes

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Under macOS Catalina using Automator I created a Quick Action setting the workflow to, Workflow receives current [image files] in [Finder], with the following Actions:

Set Value of Variable

  • Variable: [Selected Files]

Get Value of Variable

  • Variable: [Selected Files]
  • Options
    • [√] Ignore this actions input

Duplicate Finder Items

Rename Finder Items: Add Text

  • [Add Text]
  • Add: _x32 [after name]

Scale Images

  • [To Size (pixels)] 32

Get Value of Variable

  • Variable: [Selected Files]
  • Options
    • [√] Ignore this actions input

Duplicate Finder Items

Rename Finder Items: Add Text

  • [Add Text]
  • Add: _x64 [after name]

Scale Images

  • [To Size (pixels)] 64

Now repeat this again from Get Value of Variable through Scale Images set of actions three more times, changing the settings to 128, 256 and 512.

Then when you select image files in Finder and run the. e.g. Scale Selected Image(s), Service/Quick Action it will create all the files in one workflow.

As you can see by first setting a variable to hold the pathnames of the selected image files then it can be retrieved any number of times to process through the set of Actions. You just have to check [√] Ignore this actions input on each of the Get Value of Variable actions so its disconnected from the previous action so it's independent of the set of actions before it.


Note in the image below how there is a disconnect between whichever action is before the Get Value of Variable action as a result of checking [√] Ignore this actions input.

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...