ramiro.araujo Posted January 7, 2014 Posted January 7, 2014 (edited) ImageOptim Workflow for Alfred appThis is a wrapper Alfred workflow around the great ImageOptim-CLI library from Jamie Mason. Mason's library uses three image optimization applications to automate optimization of JPEGs and PNGs. It uses the open source ImageAlpha and ImageOptim apps, and the JPEGmini app, which is not free, but highly recommended. Together they shrink images like a beast.My own addition to this image processing is that if JPEGmini is unavailable, it uses ImageMagik's mogrify to compress JPEGs to quality 75, if they're actually higher than 75. To do this, I'm also bundling ImageMagik'smogrify and identify. A quality of 75 is usually pretty safe and it still has a way smaller size and usual JPEGs saved from Photoshop without optimization. That being said, JPEGmini does way better job and it's recommended. Requirements ImageOptim, installed in /Applications folder. ImageAlpha, installed in /Applications folder. JPEGmini, optional but recommended, installed in /Applications folder. If using JPEGmini, you need to add Alfred 2 to the allowed apps in the accesibility list. Go to Preferences, Security and Privacy, Privacy tab, click the lock to allow changes, and drag the Alfred 2 app into the list. Usage 1. find or select one or more images or folders, show the file actions in Alfred, and select "Optimize Images". Note that any Alfred's way of selecting files work, such us: select one or multiple files/folder in finder and press ⌘ alt \ browsing or finding files in Alfred, and triggering actions for the file saving files in Alfred's file buffer, and then ⌘ → to action buffered files. 2. You'll see a notification indicating the number of files to process. The work is done partially with AppleScript, so even if it's happening in the background, the apps are actually laoded and you can focus on them to check the status. Depending on the number and size of images, it could take a while. 3. When the optimization is completed, you'll see another notification, indicating the original Kilobytes, the current Kilobytes, total savings and savings percent. CaveatsYou shouldn't run optimizations in parallel. Tecnically you could if the batch already jumped to the next app (from JPEGmini to ImageOptim for example), but it's looking for trouble. I'll consider adding a check in the future to prevent parallel process from happening, but I'm affraid this could add other complications, as in how to clear the processing flag if optimization process is interrumpted earlier. InstallationFor OS X 10.9 Mavericks, Download the alfred-image-optim-workflow.alfredworkflow and import to Alfred 2.For Previous OS X Versions, Download the alfred-image-optim-workflow.alfredworkflow and import to Alfred 2. Source CodeClone or Fork the Workflow: https://github.com/ramiroaraujo/alfred-image-optim-workflow Changelog 2014-01-06 - Released 2014-01-23 - Added folder support, and correctly counting number of files inside folders Edited February 18, 2014 by Ramiro Araujo blkrk4000, vdesabou, Cedric and 3 others 6
RodgerWW Posted January 7, 2014 Posted January 7, 2014 WOAH, nice. One thing: your link to JPEGmini goes to ImageAlpha on GitHub. I was just introduced to ImageOptim and this workflow could not have come at a better time!
ramiro.araujo Posted January 23, 2014 Author Posted January 23, 2014 updated the workflow to support folders, optimizing contained jpegs and pngs recursively.
Colorful Tones Posted February 18, 2014 Posted February 18, 2014 I have been using ImageAlpha in tangent with ImageOptim. It has the 'Save as', and 'Optimize with ImageOptim' option. I'm wondering if it is at all possible to write a mega-workflow that encompasses both apps. I use the manual workflow so much, and it would truly be a lifesaver. BTW: https://twitter.com/dcook/status/435845604426543104 Thanks for the awesome work!
ramiro.araujo Posted February 18, 2014 Author Posted February 18, 2014 @Colorful Tones, well actually it does use ImageAlpha also, check the description! It uses ImageOptim, ImageAlpha (for pngs) and JPEGmini (for jpegs). The workflow is a wrapper around a command line library (https://github.com/JamieMason/ImageOptim-CLI) that uses all this software in combination.
billy Posted February 20, 2014 Posted February 20, 2014 Great! Thanks! I have used it for JPEG images.
kimonostereo Posted July 10, 2014 Posted July 10, 2014 Tried using this today, and while I have all three apps, all I see is the notification that says this could take some time, but then nothing happens afterward. I'm on Mavericks and downloaded the workflow for Mavericks. I also have the ImageOptim-CLI libraries installed.
ReadingG Posted September 27, 2014 Posted September 27, 2014 I just found out about ImageAlpha and liked the compression but not the time as I have lots of files to compress. I searched online and found this site/post and downloaded Alfred 2 and bought the power pack upgrade (I have no programming experience but thought I would give this a try.) I uploaded the work file for mac mavericks and downloaded imagealpha and imageoptim (I do not have the ImageOptim-CLI libraries installed like the previous poster.) I have a similar experience to the previous poster of the set-up not working on my computer. I get the the notification that says this could take some time and then........... nothing. I did not get the second message and the work was not done. I quit the program and tried again with 2 files-same thing. I quit the program and tried again with 1 tiny file that was only 3kb. I figured that would not take that much time. No second message no result after 20 minutes? I searched in the folder and in finder and found no recent png files What am I not doing? What am I doing wrong? Please help. I would love to get this to work.
kimonostereo Posted September 29, 2014 Posted September 29, 2014 Make sure that Alfred is checked off under System Preferences > Security & Privacy > Privacy > Accessibility. That solved the issue I was having.
dlewand691 Posted February 19, 2015 Posted February 19, 2015 Love having this workflow, but can you add the option to use jpegmini Pro? Thanks!!!
ramiro.araujo Posted August 28, 2015 Author Posted August 28, 2015 Yay! I've rebuilt this workflow from scratch! I now uses bundled binaries from all the different optimization libraries, all orchestrated by the image_optim library, which is great, since it now longer depends on having ImageOptim, ImageAlpha and more importantly JPEGmini installed! I'll update packal when possible, but right now you can check it out and download it from github: https://github.com/ramiroaraujo/alfred-image-optim-workflow Nolff 1
nikivi Posted March 24, 2016 Posted March 24, 2016 Hey is it possible to optimise a selected image with a hotkey? Let's say an image is selected in finder or on desktop, I press the hotkey and it optimises the image. For me that would be incredible. I hope such a thing would be possible to do. I tried doing something like this : http://i.imgur.com/Y4leiVv.png But that didn't work which I guess is expected.
deanishe Posted March 24, 2016 Posted March 24, 2016 (edited) You have to write a bit of AppleScript to use the Finder selection (unless you're using File Actions and File Selection mode).Have a look at this workflow, which uses the Finder selection.call_with_finder_selection.applescript is probably the bit you want. Edited March 24, 2016 by deanishe
magrolino Posted January 2, 2017 Posted January 2, 2017 On 8/28/2015 at 6:31 PM, ramiro.araujo said: Yay! I've rebuilt this workflow from scratch! I now uses bundled binaries from all the different optimization libraries, all orchestrated by the image_optim library, which is great, since it now longer depends on having ImageOptim, ImageAlpha and more importantly JPEGmini installed! I'll update packal when possible, but right now you can check it out and download it from github: https://github.com/ramiroaraujo/alfred-image-optim-workflow How does this effect JPEG Mini? I have the pro version installed and it looks like it is not used at all - and it's not in the bundle, right?
ixium Posted January 24, 2017 Posted January 24, 2017 this workflow was working well for me, now it just returns "25 of 25 processed / 0% reduced" so its running but not optimizing anything anymore. Alfred is checked off in the accessibility options and this works before, any ideas? ggaavviinn 1
millertime Posted July 3, 2017 Posted July 3, 2017 Hi there, thank you very much for this workflow, it saved me from having to use terminal commands to do all of this. You mentioned having a lossless option - is that still in the works? Also - how may I iterate the optimization recursively through subfolders, because I selected a folder with images and folders, which also had images and folders, but the operation only affected the first tier, not the subfolders.
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