Automator Compression w/ImageOptim + Zip Archiving Solution

If your anything like me and looking to create an automator workflow that suits your needs when it comes to export and automation then this might just be for you.

This is a workflow automation with MacOs’s Automator and doesn’t require you to have the Automator app open, just save the workflow and quit out of Automator.


I specified the folder where my exports are saved in my case its a HYPE EXPORTS on my desktop. Next, I created a zipped folder nested within HYPE EXPORTS folder, and whatever follows in the sequence of events is in the screenshot.

PS. If you’re wondering why Pause for 30 seconds? I estimated based on the images I have 30 seconds should suffice for imageoptim to run its compression.

This workflow ensures all of my Hype resources images are intact in the resolution I brought them in originally.

If anyone has an easier solution I’d like to see it. Ideally I’d love it if Hype had this type of functionality built-in when exporting but not a necessity as its custom workflow.

1 Like

Looks good only part is the time delay. Would be the best if ImageOptim could actually be tested for completion of the task. Check out the terminal option that actually allows for blocking (hence waits for completion). Maybe you could add that to your flow instead of the wait…

yes thats what I was looking for but couldn’t find the exact shell command. :frowning:

Make sure you specify the correct path to optimize… you don’t want to optimize your whole Hard drive rather only the files in the exports folder or on a finder selection or on a Hype file dropped on the action :slight_smile:

Of course, Its set to specific folders and I ran it it works correctly. Let me see maybe I can tweak this with the script command line, the 30 seconds was just a band aid - unfortunately.

1 Like

Would this do it?

Headless actually doesn’t need to be quit. Also, you should send it the correct path… so use Pass input as “to arguments” and the (not tested if the blocking is respected by automator!).

for f in "$@"
	/Applications/ $f 

Ok yes I meant to remove the Quit Application. hmm that didn’t seem to work buddy. I changed the pass input to be “as arguments” that too didn’t work. Gear icon is spinning and not really working.
bash/bash opens imageoptim but its no starting the operation.



for f in "$@"
	/Applications/ "$f"
	echo "$f"
1 Like

Below did it! Thank you :+1: (115.9 KB)

Sure that the *.png needs to be in there?

According to the documentation it states the following: Unless I understood it incorrectly which happens frequently. :grin:

This will launch ImageOptim with hidden UI and optimize all *.png files synchronously . The command will block and wait until all files are optimized.

In my case the Archiving is after followed by the reveal finder items.

Actually, you don’t need the *.png in my opinion as we are passing in "$f" being each item added to the watched folder or each dropped item (if used in an Automator program). A regular exports adds a HTML-file and a resource folder. Each is being passed to ImageOptim and I guess ImageOptim ignores the HTML and traverses the Folder.


Yes It does just that.

The reason why I have above as per their instructions they say it ui is hidden and waits after until after all is compressed and moves to the next automation or as I understood it?

Let me see if i really need it will report back if its actually needed or not.

@MaxZieb yes sir you are correct, it does work without the *.png thank you.

1 Like