Image Resizing Macro

Yes, I’ve seen this, too. Happens for me when the height already is ≤580px.

but when the image is greater than 580, this is the error I get

https://www.dropbox.com/s/es3txl3p2h7rzyg/Banners_and_Alerts_and_Image_resizing_macro_-general-_Keyboard_Maestro_Discourse_and_Win_your_FREE__100_for_Pok%C3%A9mon_Go.jpg?dl=0

Tried it with a couple of PNGs and can not reproduce the error.

The image is OK? (Can you open it with Preview for example?)
You have tried it with different images, right?
Have you tried it in different locations (folders)?

BTW, ImageOptim doesn’t read TIFFs. Didn’t know this. (Resizing works fine though.)

Yes I’ve tried with several different JPGs. I don’t use PNGs much, so they’re not relevant in my workflow.

Different folders/locations too… :frowning:

I tried it again, with JPGs this time. Can not reproduce the error.

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.

1 Like

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:

Read File to Clipboard
Resize Image on System Clipboard

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.

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

I leave it up to you if this is a “bug” or “non-intuitive behavior” :wink:

1 Like

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. I’ve attached an example image I’m trying it on:

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.)

***

Could you also verify that you are really using the latest version of the macro, that is, the one with the actions for resetting the image to 72ppi.

(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:

  1. Delete all old versions of the macro in KM Editor; delete all old versions of the .kmmacros file in your Downloads folder.
  2. Download the new one from the updated link in my first post.
  3. Double-click the .kmmacros file in your Downloads folder.

Hey Tom

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).

Is there a simpler way to accomplish this?

Hey eranbeard,

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…

  1. 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)”,
  2. then drag all the resized images in the output folder into ImageOptim.

Highly recommended :slight_smile:

1 Like

For the next versions, I have adjusted the resizing actions so they always operate on pixels, regardless of DPI.

2 Likes

Thanks for the explanation. I redownloaded the macro, but all that happens is that my image runs through imageoptim but the size remains the same (ie more than 580px). I’ll record a screencast if that helps?

Ah, you are back and didn’t throw in the towel prematurely. Fine! :wink:

I'll record a screencast if that helps?

Why not.

all that happens is that my image runs through imageoptim but the size remains the same (ie more than 580px).

  1. Just to be sure: The size remains exactly the same, or it is not the same but still more than 580px (height)?
  2. Are you still getting the “cannot get source” error?
  3. I noticed that in your penultimate post you said you want to convert to “580px wide”. Was that a typo? (Until then we’ve been speaking of the height, and the macro is set to fit the image to a height of 580px.)
  4. Could you please try to run the macro on the attached image and report back?

288ppi.png.zip (3.6 KB)

Hi Tom

Please watch this:

I show the image dimensions at the start, then run the macro by pressing Command + 2 (this isn’t shown in the screencast). Nothing happens, Then I open KWM to show that the macro is running, then run the macro again. This time the ImageOptim part of the macro runs correctly. I open up the image info to show the size, but it’s not shown, so finally I open it in Photoshop to show that the image size hasn’t been converted to 580px WIDE.

Any ideas what’s going wrong?

The video doesn’t play for me. Maybe it’s still uploading, I’ll check back later.

In the meantime, please —if you find the time— could you try to answer the four questions from my last post?

Thanks.

Just to be sure: The size remains exactly the same, or it is not the same but still more than 580px (height)?

I mean, the size of the image remains unaltered after running the macro.

Are you still getting the “cannot get source” error?

nope

I noticed that in your penultimate post you said you want to convert to “580px wide”. Was that a typo? (Until then we’ve been speaking of the height, and the macro is set to fit the image to a height of 580px.)

sorry yes, typo.

Could you please try to run the macro on the attached image and report back?

still doesn't alter the size

Here’s the video again:

According to your video the original dimensions are 6016×4016 (a bit hard to read) and at the end (in Photoshop) they are 1738×1160.

So, unless I’m missing something, the dimensions are not unaltered. Since 1160 = 2×580 it points to the ppi problem, as discussed in earlier posts.

However, this problem should be solved by the If…Then action in the macro. I have no clue why it isn’t.

Well, we can do two things:

  1. Can you post a link to the unaltered original image?
  2. Below you find a debugging version of the macro. It will output size and ppi information from three different stages of the macro, like this:

Can you run the debugging macro on two or three images, where at least one of them has a resolution higher than 72ppi?

For each image: Write down the Original values (size & ppi) according to Photoshop. Run the debug macro and copy the results from the debug messages. Write down the Final values (size & ppi) according to Photoshop.

Post the results.

Resize Image (Debug).kmmacros (12.6 KB)

BTW, it’s a good idea to change the hotkey of the macro, since ⌘2 is also used in the Finder for the list view.

I am trying to use this Macro to simply

Resize images in finder to be
600 x 600

I removed the part of opening the image in ImageOptim but I cannot seem to get the image to resize and save a new file

Am I making this overly complicated?