You Can Use JavaScript in Photoshop?

Yes. Yes you can. It’s really quite awesome, and yet another reason I believe JavaScript is on track to be the only language an app/game developer needs to focus on working with.

This session was titled “Intro to Photoshop Scripting for Artists” and was presented by Greg Hendrix  |  Technical Artist, npnf

First up is the summary from the GDC site, followed by my thoughts.

Session Summary

“An introduction to scripting in Photoshop using Javascript. Even if you’re a complete programming newbie, this talk will get you excited about how Photoshop scripting can improve your workflow and efficiency.” –

Hodge’s Thoughts

Most of us know that one can record actions (or macros) within Photoshop. What I didn’t know is that Adobe allows one to write their own script logic to execute commands within Photoshop, and it’s not Action Script.

Action script has long been Adobe’s scripting langue, and I’ve used it in AfterEffects and Flash to write expressions; however, with Photoshop we have our choice of three different langues and AS isn’t one of them. Go figure.

The three we have are:

  • AppleScript – only works on Macs
  • VBScript – only works on Windows
  • JavaScript – works on everything, so why even bother with the first two

The speaker spent a bit of time on the concept of variables and “if” statements. That part was needed because many in attendance are artists only and don’t program. If one is only an artist the information probably didn’t sink in, but I felt he did a good job explaining with the time he had. He certainly made the case for why artists should learn basic programming concepts.

The way it works is very familiar to anyone who’s ever done OOP (Object Oriented Programming) with JavaScript, or any language really.

Scripting for PhotoshopA file open in Photoshop is an active document. One can assign the active document to a variable and access properties such as size and tasks such as re-sizing with a dot member system. I’m not going to try and explain what all of that means. If you know, then have a look at the pictures in this post and you’ll get the idea. If you don’t know, it’s time to learn programming with JavaScript 😉

The scripts are best written inside of Adobe’s Extend Script Toolkit. This tool kit includes the functionality to run scripts on the currently active Photoshop file. To find out all of the properties and functions available for script editing, consult the Adobe Photoshop Scripting Reference.

Everything you need to know can be found from the Adobe Scripting Center.

As a final thought, I love this because I now have something to throw in my artist student’s faces when they give me grief for trying to teach them to program. I make everyone spend at least two weeks learning the basic concepts of programming with JavaScript. My artists always question the point of it for them. Now I can say “so you can use Photoshop in ways that make you better, faster, and smarter than your competition in the market place.”

Thanks for reading and stay tuned for more GDC posts throughout the week!

Leave a Reply