null Posted January 7, 2022 Share Posted January 7, 2022 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
Chris Messina Posted January 7, 2022 Share Posted January 7, 2022 (edited) 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 January 7, 2022 by Chris Messina Added TinyPNG link null 1 Link to comment
vitor Posted January 12, 2022 Share Posted January 12, 2022 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. Chris Messina and null 1 1 Link to comment
null Posted January 29, 2022 Author Share Posted January 29, 2022 thx @vitor! this looks cool, although i will have to read it a few times because i'm not familiar w script actions. do you know if there is a workflow already for this or if this can be turned into one? Link to comment
vitor Posted January 29, 2022 Share Posted January 29, 2022 Untested but should work. Link to comment
null Posted February 22, 2022 Author Share Posted February 22, 2022 On 1/29/2022 at 2:37 PM, vitor said: Untested but should work. it works great for me! thnk you 🙏🏽 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now