I was actually looking for automator to be able to do this, but it looks like it can only scale. I’d like to be able to run this applescript on a folder, to where it opens up each item in say Preview, and changes the resolution to X dpi and the image to 256 colors. I’d also like to be able to convert the images to RGB, but I don’t think Preview supports this.
Speaking of Automator… running into some weird issues with it—
I set up a flow where a file is dropped in a hot folder (input folder) then simply copied to four subsequent folders. Each time I add a file to the hot folder, I get different results (sometimes it copies the file to 1, 2, 3, or all 4 folders). Any thoughts on why?
My Automator flow is setup such as “Get Folder Contents” → “Copy Finder Items [Folder 1]” → “Get Folder Contents” → “Copy Finder Items [Folder 2]” … and so on, with the script set as a folder action on the input folder.
Alternately I set it up to do “Get Folder Contents” → “Copy Finder Items [Folder 1]” → “Copy Finder Items [Folder 2]”… etc, and am getting the same mixed results each time.
I’ve never used Automator at all, and don’t know where to even begin diagnosing the actions and exchanges between them and Folder Actions (which I’ve started to use recently, but only sparingly). Sorry.
tell application "Finder"
set the in_files to (every item of (choose folder))
on open the in_files
repeat with previewMe in the in_files
tell application "Image Events"
set this_file to (POSIX path of (previewMe as alias))
set this_image to (open file this_file)
set target to 600 -- width or height, whichever is larger
scale this_image to size target
save this_image in this_file as JPEG --with icon
Image Events doesn’t know about “resolution” or “ppi” - only pixel dimensions. Something like this should work for your scaling. I don’t know how to change the color depth from 24 to 8 bit, but it should be possible.
Prior to doing this I was having reliability issues - where certain “triggered folder actions” would only work sometimes, or would work when I’d move an item to the trash (as opposed to when I copied the file into the hot folder), etc.
So essentially I teamed up automator, a free “Photoshop Automator Pack” and built some photoshop actions to do the job. It takes one master image, and outputs it now five different ways. Unfortunately, you must make sure to only have one file open/running an action in Photoshop at a time, otherwise the automation will try running on top of multiple images and end up not working or doing the wrong things to the wrong image. So unfortunately, you can’t “batch” drop in files, it’s limited to one at a time. But it should work for what I’m looking to do.