Keyboard Maestro Resize Image Macro
Here's a macro to take advantage of the new Keyboard Maestro 5.3 Image actions. This macro processes an image (or several) selected in the Finder. If the image is larger than 600px wide, a new scaled copy is created that is 600px wide. But the trick is to scale both dimensions relatively, not just squash the image on the X-axis.
The macro is a bit long but most of it is straight forward. The first steps involve getting the file path, name and extension. This info is used later to write the new version of the file with the suffix "600px" appended to the file name.
I only want the macro to process images that are larger than 600px wide. I added a test to the macro where I extract the image dimensions (with the new KM image dimension action). I then check the image width (held in temp[1]) to see if it is greater than 600px.
The real trick in this process is to resize the image height relative to the 600px width. To do that I use the Keyboard Maestro Image resize action, but I set the dimensions with a calculation rather than an integer. This is useful option that is often overlooked in KM. Any field that accepts an integer value will also accept a calculation that generates an integer at run time.
Finally, the macro saves a new version of the file without overwriting the original. The new version gets the same base file name but with a suffix appended.