January 31, 2007

Useful Photoshop layer-handling scripts

Last week Ralf Berger, co-creator of Photoshop's Vanishing Point tool (and formerly eng. manager for LiveMotion), asked me whether Photoshop offered a way to clean up files by deleting empty layers.  I knew that the Layers palette fly-out menu contains a command to delete hidden layers, but not one for blowing away those with no pixel content.  After a nudge towards the Photoshop JavaScript guide (installed in the application folder, btw), Ralf whipped up this script for deleting blank layers.  I'm posting it here in case it's useful. (You may want to right-click/Ctrl-click the link to download the script, then put the file into your Photoshop folder under Presets/Scripts.)

On a related note, I came across a Trevor Morris's trove of handy-looking little scripts.  And for more PS scriptiness, including a good discussion forum, check out PS-Scripts.com.

Posted by John Nack at 12:44 AM on January 31, 2007

Comments

Patrik — 4:56 PM on February 7, 2007

Hi John,
Thanks for the script. I had written a similar thing in Applescript but I am sure the javascript will run faster.

Do you have any similar scripts that allow me to copy a warp from one smart object to another. Or a script that makes layer comps based on prefixes.

[Patrik, I don't have anything myself, but you should definitely try the Photoshop scripting forum, Adobe Exchange, and similar resources. --J.]

I do a lot of versioning in my office and am often faced with having to make prototypes before the items exist. I make them out of press ready files and a photoshoot of a blank book. Therefore my need of copying warps. So that I can do 15 languages at once. Also any idea on automatic generation of layer comps based on a prefix and set background and foreground layers that are always on.

Best, Patrik

Troy — 11:49 AM on March 5, 2007

Thanks, John, that's exactly what I was looking for. Checking out the source code for it I feel kinda stupid for even searching... I didn't even think to simply test the bounds of the layer to determine if it was empty (shows how often I do PS scripting).

I did notice that its surprisingly slow. I've got a bunch of PSD's that have a few hundred layers each (of which 90% are empty due to some limited PSD export from an animation package we're using) and its taking around 10 minutes to delete all the empty layers in one file (the PSD is 256x256 in size). This surprises me... does it match the speed you're seeing?

[Hmm--that does sound slow. Let me inquire with the team. Thanks for the heads-up. --J.]

Alex — 6:41 AM on March 13, 2007

WOW! This is great! Thank you. This is the kind of thing I love.

Aaron — 12:00 PM on April 3, 2007

Was wondering if anyone had any advice. I used Trevor Morris's Search For Layers Script. Works but only searches layers that are "not" in a folder. Any feedback to what I need to change in the script to search for layers that are inside folders?

Moritz — 7:46 AM on November 4, 2008

Hi John

how do I install this script?

Thanks in advance..

mo

[Just download the file to your hard drive, then copy it and move it to your Adobe Photoshop CS3(4)/Presets/Scripts folder. When you launch PS the script will appear under the File->Scripts menu. --J.]

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

Remember Me?