Jump to content

Recommended Posts

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 

 

 

Share this post


Link to post

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.

Share this post


Link to post

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 

Share this post


Link to post

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

Share this post


Link to post

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.

Share this post


Link to post

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 

Share this post


Link to post

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.

Share this post


Link to post

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 by macmac

Share this post


Link to post

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.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...