macmac Posted November 8, 2015 Share Posted November 8, 2015 I wonder if anyone can help me. I have been using Ramiro's workflow (the first version) for imageoptim-cli and it has worked brilliantly: I simply used Alfred to find the image on my desktop and then just chose the Optimize Images action to run it. Perfect. However now I'm getting good results from ImageMagik's command line tools and would like a similar workflow. This is what I run in terminal: convert /Desktop/myimage.jpg -strip -quality 75 -interlace line /Desktop/myimage2.jpg How could I turn that into a similar workflow? Many thanks Link to comment
deanishe Posted November 11, 2015 Share Posted November 11, 2015 Running the command on a file is entirely trivial to do.The question is: how does the input and output work? You want input via a File Action, which is super simple. But what about the output files? Are the original files replaced? Are the optimised files saved to the same directory as the originals with a different name, e.g. NAME.optimised.EXT? Are they saved with the same name, but to a different directory? Are the original files renamed to, say, NAME.orig.EXT, and the optimised versions saved under the original names? Unless you're overwriting the originals, some manner of path/filename manipulation is going to be necessary. Link to comment
macmac Posted November 11, 2015 Author Share Posted November 11, 2015 Thanks very much deanishe I don't mind overwriting the file if it's easier to create a workflow like that but currently when I enter the path for /myimage.jpg into the terminal I also enter something like /myimage2.jpg into the second part of the code and that is what is output. Usually to the same directory. I mean it would be great if it set up a new folder like the tinypng workflow does for optimised images but that would only be vital if there was no way to output a new filename and it was consistently a problem to overwrite the original. thanks Link to comment
deanishe Posted November 24, 2015 Share Posted November 24, 2015 Did you decide how you want this to work yet? Link to comment
macmac Posted November 25, 2015 Author Share Posted November 25, 2015 Hi deanishe The way I'd like it to work would be to use Alfred to navigate to the image (which is likely to be on my desktop - eg /Desktop/myimage.jpg as per original post) and then to be able to use the right arrow to select an action which will run the convert script. Like this: https://www.dropbox.com/s/vz64pgyh89vy759/Screenshot%202015-11-25%2010.58.14.png?dl=0 It would be great if it could assign a new name to the converted image in order to keep the original but not essential. Many thanks Link to comment
deanishe Posted November 26, 2015 Share Posted November 26, 2015 Give this a try. Note: I don't actually have ImageMagick, so it's only been tested with GraphicsMagick. There's an option at the top of the script, RENAME_ORIGINAL, which if set to True will rename the original file and save the optimised version under the original name. Link to comment
macmac Posted November 26, 2015 Author Share Posted November 26, 2015 Thank you very much deanishe Unfortunately I just get an alert: no such file or directory I installed GraphicsMagick - as you used that to test - but got same result. Thanks Link to comment
deanishe Posted November 26, 2015 Share Posted November 26, 2015 You need to open up the Run Script action in the workflow and configure the settings. The comments in the script explain what stuff does. In particular: # Perform conversion with ImageMagick convert = ['/usr/local/bin/convert'] # Perform conversion with GraphicsMagick # convert = ['/usr/local/bin/gm', 'convert'] # Options to pass to `convert` command convert_options = ['-strip', '-quality', '75', '-interlace', 'line'] For ImageMagick, you need to change the corresponding setting to point to the right place: convert = ['/usr/local/bin/convert'] to: convert = ['/the/place/you/installed/convert'] If you want to use GraphicsMagick, you need to uncomment the corresponding line: # convert = ['/usr/local/bin/gm', 'convert'] to: convert = ['/usr/local/bin/gm', 'convert'] If you uncomment the GraphicsMagick setting, that will override the ImageMagick one. Link to comment
macmac Posted November 27, 2015 Author Share Posted November 27, 2015 (edited) Got it now deanishe Thank you very much. That's great. I must look into the difference, if any, between ImageMagick and GraphicsMagick. But that workflow is just what I wanted. Thank you. Edited November 27, 2015 by macmac Link to comment
deanishe Posted November 27, 2015 Share Posted November 27, 2015 I must look into the difference, if any, between ImageMagick and GraphicsMagick. I don't really know. In practice, if you have GraphicsMagick, instead of using convert, you use gm convert and so on. 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