Texture Geekery And Trivia

Here are some other random tidbits that you might find interesting if you want to know just what the hell Dirty Pictures is doing under the hood.

How was it made?

Dirty Pictures was written in Javascript, via reference to the Javascript SDKs included with Photoshop. There are about 2600 lines of code in the v0.8 beta that’s current as I write this. Javascript in Photoshop gives all the automation capability that actions provide, plus file I/O, user interface functions, and most importantly, the ability to do different things in different circumstances (conditional logic). Unlike a full-blown Photoshop plugin, it doesn’t requires any machine-specific compiled code, which is less stuff for me to mess up, and it means that we only need one actual code base.

Thanks to Adobe for writing the Extendscript Toolkit, and to PS-Scripts.com for being a badass resource for getting over specific hurdles. Also to xbytor, who I haven’t had any personal contact with, but who writes and shares a ton of Photoshop code. The wisdom shared on the net made many of the little features in this program possible, as many of them rely on hacking the stuff that Adobe provided us with, or on using undocumented features.

Where are all the files?

On the Mac, all the Dirty Pictures files are stored in /Library/Application Support/Totally Rad Dirty Pictures. Don’t go changing anything in there. You’ll just mess it up. However, if you’re looking for the actual jpg files in the Dirty Pictures library, either because you’re curious, or because you want to be a dick and upload them to bittorrent or something… there they are.

The actual dirtypictures.jsx file, the one that runs everything, is a link from the file in /Library/Application Support/Totally Rad Dirty Pictures/Dirty Pictures Support Files to the scripts directory in your Photoshop install. It’s created at install time. Moving the actual file to the Photoshop scripts directory works, too, but it’s messier to install / uninstall, especially if you have multiple versions of Photoshop running (if you’re geeky like me).

On the PC, the files are found in a subdirectory of %APPDATA% (an environment variable used by Windows to find certain stuff). On XP, that’s typically C:\Documents and Settings\{username}\Application Data, and in Vista, it’s typically C:\Users\{username}\AppData\Roaming. We make a Totally Rad Dirty Pictures folder in that folder and put our stuff there. In Vista, this whole folder tree is hidden by default, though you can get there by typing %APPDATA% into the location bar of Windows Explorer, or typing cd %APPDATA% into a command prompt. Confusing, huh? Better off just buying a Mac ;).

On Windows, we also copy the actual dirtypictures.jsx file to the Photoshop/scripts directory (usually c:/Program Files/Adobe/Adobe Photoshop CS4/Presets/Scripts)

How are the masks configured?

Since people really liked being able to pick apart the Totally Rad Actions to see how they work, and since that isn’t really possible with scripts, here’s a quick explanation of how you’d set things up Dirty Pictures style, without the script (for pure acdemic reasons)

Open up your texure file, copy it, and paste it into the photo you’re working on.

Rotate and scale your texture file so that it completely covers the photos you want it to apply to, with the minimal amount of scaling. As a geek aside, early development versions of Dirty Pictures included options for configuring rotation (in 90 deg incerements or auto), and whether to preserve the aspect ratio of the texture.

Duplicate the texture layer, while the blending mode and opacity are still normal and 100%.

Clip that layer to the original texture layer with alt+cmd+g (alt+ctl+g on the PC). This means that the topmost layer will only affect the layer below it.

Blur the duplicated, clipped layer (Gaussian Blur, 100px)

Add a layer mask (optionally inverting it by holding alt while clicking the mask icon) to the duplicated, clipped layer.

Change the blending mode and opacity of the original texture layer (the lower one) to the settings you want.

Go back to the layer mask on the top layer and use that to pull the texture out of the areas you don’t want texture on.

That’s sorta the solution we came up with for having a texture in a photo, and allowing you control over where the more detailed, prominent texture details showed up, while still allowing the general color and tone shifts of the texture to work all over. I didn’t think it was a particular stroke of genius, because I’m admittedly ignorant in most cases as to how other people do things, and this seemed like the inevitable way to do it… but it seems like a revelation to many, so I thought I’d share, in case someone can learn from it.

Why aren’t all of the blending modes available?

Because I couldn’t find any situations in which the excluded ones actually produced a result anyone would want with the textures in our library. If you really, really want a particular blending mode available that isn’t there, let us know.