I have been using Automator to check image files for a long time now but have wanted to switch it over to keyboard maestro and now seems to be a good time with the impending switch from Automator to "Shortcuts". The biggest issue with switching programs has been figuring out how to implement the AppleScripts setup in Automator within KM. Currently have two AppleScripts each one checking a different image property and tagging items in the Finder that match the criteria. I didn't write the AppleScripts for the Automator so not sure how they work/how I can implement them (*using KM variables as input).
Image properties to check:
Dimensions of the image match 2000px x 2667px or 36px x 36px (Tag yellow if not)
Image resolution matches 72 PPI (Tag green if not)
The third check I haven't been able to implement is tagging image files that are not using the sRGB colour profile. Please let me know how I can implement these Applescripts or if there is a better way of doing this.
Applescript used to check dimensions
on run {input, parameters}
set final_list to {}
repeat with ea_ch in input
try
tell application "Image Events"
close images
set b to open (ea_ch as alias)
set c to dimensions of b
set d to resolution of b
close b
end tell
if not (((c's item 1) * (c's item 2)) = 5334000 or ((c's item 1) * (c's item 2)) = 1296) then set end of final_list to (ea_ch as alias)
end try
end repeat
return final_list
end run
AppleScript used to check PPI:
on run {input, parameters}
set final_list to {}
repeat with ea_ch in input
try
tell application "Image Events"
close images
set b to open (ea_ch as alias)
set d to resolution of b
close b
end tell
if not (((d's item 1) * (d's item 2)) = 5184 or ((d's item 1) * (d's item 2) = 5184)) then set end of final_list to (ea_ch as alias)
end try
end repeat
return final_list
end run
It varies by the day but can range from 100 - ~1000 images, Automator usually take a minute to process the files so I know it won't be an instant process
Only checking jpg images, no other types should be within the folders
Awesome thanks for your help with this! How do I run the script just select the folder in Finder and run it with the keyboard shortcut? (Does it automatically pull the files from the folder?)
Also, is it possible to send a list of files through the script using a variable? I.e.
I didn't realize Keyboard Maestro could do this natively, however after some looking around I found someone on the forum using a shell script to get the dimensions of a video and after some googling found I could also use it for photos. Attaching how I setup the script, any comments/improvments are welcome!
Tag Images that don't match set Resolution/Dimensions Macro (v9.2)
I really appreciate you taking the time to write those initial scripts! I'm usually pretty good with searching the wiki and solving my macro problems but I got stuck trying to reimplement the AppleScripts and I just didn't think KM could pull the image properties natively. But again I do appreciate all your help!