I’m pretty new to AppleScript, but I’ve really been having fun learning how to use it. I’ve recently been working on my first useful script and need some advice.
I need to take a bunch of images from a folder, get the filename, remove the extension, then overlay the remaining text on the image so it can be seen when viewing the image.
So far, I’ve created an action in Photoshop that works ok, but ideally I’d like to be able to script the whole process without using actions. Is that even possible?
I really appreciate your advice on how to get started.
This is not fast nor smart (it tries to open every file of a folder regardless of the file type and it will work on the original file so make sure you have backups if you don’t like the way this works!) but it does work. It may not provide you with everything you want but it will be a good start. You can run this directly from Script Editor or save it as an application and drag and drop the folder full of images you want to process on to the new app’s icon in the Finder.
Thanks for the script. You saved me a ton of time.
You mentioned that htis script isn’t fast or smart. Can you elaborate? I’m going to be using this a lot, and I’m curious about what you mean.
Also, I tried to change the color of the font, but it doesn’t seem to work. I added:
tell text_ref
set contents of contents to the_name
set size to 20 as points
set font to "Helvetica"
set justification to center
set position to {(doc_width / 2) as points,(doc_height - 10) as points}
set strokeColor to (255, 255, 255)
Also, when I make this change, the script stops working. It opens all the images in photoshop, but doesn’t create the text layer. Any ideas?
I do not have photoshop, so I don’t know if you have the strokeColor named correctly, it looks odd in comparison to the other names. What I do know is that you need to use the curley brackets.
Where you have set:
set strokeColor to (255, 255, 255)
that should probably be:
set strokeColor to {255, 255, 255}
Now to blowing my own trumpet. My application iMagine is much faster than Photoshop for this type of thing. It has been designed to do these sort of AppleScript operations and the applescript interface is not based on a user interface. Once you have got your script working as you would like, you can have the whole operation performed offscreen for greater speed.
It bugs me to no end when people won’t just try for themselves. I did play with the Photoshop dictionary for a few hours last night, but couldn’t figure out how to make this simple change. I eventually resorted to calling an action, but that didn’t give me the results I wanted.
The problem is my syntax was completely wrong, and I didn’t see any examples listed in the dictionary. I’ve now started going through some basic tutorials to get familiar with that and hope to stop posting stupid questions soon. :oops:
At any rate, I do appriciate you taking the time to help out.