Please can someone help me create a macro so resize an image to Height: 580px (width can be anything), then opens the image in ImageOptim for it to be compressed using that free app’s default settings.

Ideally, here’s what I’d like to happen:

I single click an image in a Finder location or on my desktop

I hold down Command and press ‘2’ - my shortcut combination

The macro resizes the selected image to 580px high and overwrites the existing image, saving it in the same location.

Then, automatically the image is opened in ImageOptim, compressed, saved and then ImageOptim is closed.

In other words, I’m looking to create a macro that will resize and compress an image.

Yes, well, thanks: single-click the link for downloading the macro, then double-click the downloaded macro for importing it, then add your personal trigger to the macro. I was —stupidly— assuming that people know that macros are importable from the link.

Edit: to make it easier: I added the the hot key trigger to the macro, so single-click the link below, double-click the downloaded macro (it will be imported to KM), and fine. Hit ⌘2 to execute the macro.

thanks Tom. The reason I was clarifying what to do after importing the macro and creating the short cut key is that the macro doesn’t seem to execute properly. I downloaded your new version which you kindly created for me, but the same error appears - I screen shotted it, although it’s been truncated. Any ideas what the issue may be?

However, in the process I discovered another potential source of error: The KM resizing action doesn’t like images with a resolution other than 72ppi. But in that case I get the “Resize Image failed to scale by 1.000…” error (not the “cannot get source” error).

This problem can be solved by “resizing” the image to its original dimensions, just before the Resize Image to Fit action:

You can download the complete macro with the Resize action added from the updated download link in my first post.

However, in the process I discovered another potential source of error: The KM resizing action doesn’t like images with a resolution other than 72ppi. But in that case I get the “Resize Image failed to scale by 1.000…” error (not the “cannot get source” error).

I don’t know what you are referring to. If you have a bug with resizing an image, email me the image and the action so I can look at it. Preferably email me an image file, and a sequence like:

Peter, thanks for forcing me to have a closer look into this. It’s actually a bit more complicated, and I remembered that I already had this “problem” in a slightly different context.

If the error appears depends on the actual image dimensions and on the actual resolution. But the calculation for the error threshold is quite simple: resize height ≥ image height/(image resolution/72).

That’s why it works as expected with the “normalizing” actions from my post above.

peternlewis:

If you have a bug with resizing an image, email me the image and the action so I can look at it.

I’ve sent you a mail with a minimal macro and a couple of test images in different resolutions. Instructions in the mail.

Thanks for your efforts Tom, but all this macro seems to do for me is run the image through ImageOptim - the dimensions stay the same.

Yes, when the Resize action fails with a “cannot get source” error (as you mentioned above) the image won’t be resized. The problem is that I didn’t see this error not one single time, and I have no idea how I could reproduce it.

In addition, the image you uploaded seems to be OK and the latest version of the macro resized it flawlessly to 580px height.

***

What I currently don’t understand is how the image can be run through ImageOptim after the Resize action has failed. The Resize action is set to “Failure Aborts Macro”.

***

Another thing I noticed is that the height of your example picture is 1160px, and according to the JFIF header it has been stored at 144ppi.

Can you verify if the original height of the image was in fact 1160px, or maybe a little more, like 1200 or so?

(I’m asking because 1160px = 580px*144/72, which corresponds to the formula in my post above.)

(When you import a new version of a macro that already exists in the KM Editor, it can be confusing, because both are enabled. It already has happened to me, too, that I downloaded a new macro version and than accidentally disabled or deleted the new one in KM Editor.)

Or, if you are not sure, do just this:

Delete all old versions of the macro in KM Editor; delete all old versions of the .kmmacros file in your Downloads folder.

I really appreciate all your help but this is getting way too complicated. All I want is a simple way to convert any image with a size over 580px wide to 580px wide. If it makes things simpler, we can remove the ImageOptim element.

Previously I’d have dropped the image on a Photoshop droplet I have on my desktop that automates the task. I created a macro that did this, but for some reason my computer’s CPU went through the roof after I ran it (something to do with pausing untill Photoshop had completed I think).

I really appreciate all your help but this is getting way too complicated.

Well, it’s you how decides if you want to drop your project.

Until now I wouldn’t call it “complicated”. I would rather say the “cannot get source” error has stopped you in the tracks before the project had a chance to become complicated ;-).

As mentioned, I cannot really help you with this error. Since you get this error with various images and in various different locations on your disk, something big must be wrong. You should maybe even consider reinstalling KM. (BTW, you are using a more or less recent version of KM, right? Not version 4 or 5 or so?)

However —as said— it remains the mystery how the macro can continue after this error with the ImageOptim part. Because of that my suspicion was that either you are inadvertantly using an old version of the macro, or that the macro has been changed or damaged somehow.

That’s why I recommended you to start over with a fresh download of the current version of the macro.

If with “too complicated” you mean the informational content of some of the posts here, then let me assure you, you can completely ignore…

post 12 (the shown actions are integrated in the latest macro version)

posts 15 and 16 (these were not meant for you and don’t affect your current problem)

If it makes things simpler, we can remove the ImageOptim element.

You can remove this part entirely without problems. But it won’t help you because it’s not involved into the image resizing action at all. It’s just the second half of the macro which will be executed after the first one has finished.

But removing it won’t harm either.

Is there a simpler way to accomplish this?

There is an app that is specialized in all kind of batch image manipulations. It’s called GraphicConverter and it costs $40. This is a bargain, especially if you do this kind of stuff often (e.g. resizing, scaling, cropping, adjustments, effects; either in batch mode or individually. It can even crop JPGs losslessly, i.e. without recompression).

So you could…

set up a batch action in GraphicConverter (this is simple: you set the input and output folder and add the appropriate action, in this case: “Scale (Long Edge)”,

then drag all the resized images in the output folder into ImageOptim.