Jump to content

process screenshots w imageoptim

Recommended Posts

almost everytime i take a screenshot on my mac, i want to process it imageoptim. i found a bunch of workflows already (for example here and here) but none process the image automatically.


does anyone know of any workflows that will automatically shrink screenshots via imageoptim?  ie: take a screenshot, automatically process it via imageoptim?


ps - an even cooler flow would include uploading it to my dropbox and adding the link to my clipboard but that's a lower priority

Link to comment

Maybe @Mr Pennyworth could add this to his Cleanshot Workflow (if you're willing to try Cleanshot).


Another way to solve for this is to attach a Folder Action (unrelated to Alfred) that runs an ImageOptim CLI script any time a new image is added to your Screenshots folder, which you can set by using this command:


defaults write com.apple.screencapture location /path/;killall SystemUIServer


This blog post about @vitor's TinyPNG Workflow may also be relevant.

Edited by Chris Messina
Added TinyPNG link
Link to comment

All you have to do is use the screencapture tool which ships with macOS to take the screenshot, then compress it. It’s done in three short lines in a Run Script Action with default options:


readonly image="${HOME}/Desktop/$(date).png"
screencapture "${image}"
open -a 'ImageOptim' "${image}"


If you want the screen capture to be interactive, change the second line to screencapture -i "${image}". If you want more options, open a terminal and run man screencapture.

This method will open ImageOptim’s GUI, though. I’ve opened a pull request with one of the Workflows you linked to add support for an External Trigger. Meaning that if they merge it (or just download this version which is ready), you can replace the third line from above with:


osascript -e "tell application id \"com.runningwithcrayons.Alfred\" to run trigger \"optmize_image\" in workflow \"ws.willner.alfred.imageoptim\" with argument \"${image}\""


And it will do what you want.

To trigger the code, use whatever you want. You’ll likely want a Hotkey Trigger. If you want to use the default screenshooting shortcuts, you’ll have to disable them from macOS in System Preferences → Keyboard → Shortcuts → Screenshots.

Link to comment
  • 3 weeks later...
  • 4 weeks later...
  • 1 year later...

i absolutely love this workflow and would pay to support it. with that said, ive noticed recently it's a bit inconsistent. ie: images aren't crunching as much as possible (i have to manually re-import into imageoptim), sometimes a bit slower, etc)


just curious if anyone is experiencing the same?

Link to comment

The workflow just sends the images to the ImageOptim app, so any crunching problems will have to be reported there. But the app in turn is just a frontend for a bunch of command-line tools, so they might ask you to report to the specific projects instead.

ImageOptim does have an ↻ Again button, so you shouldn’t have to manually reimport. It has always worked like that, it’s expected that repeated crunches yield smaller results, but way slower and most of the time not worth the extra reduction.

Also, check ImageOptim’s preferences, as you can turn on and off different compressors.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...