Skip the how-to and download the “Export single” action for Photoshop here.
Everybody has their own flavor when it comes to exporting assets in Photoshop. I’m personally a sprite sheets kind of guy, but I’ve also been using Slicy from MacRabbit from time to time. No matter the method I use, there are always situations when I need to do quick fixes and export from a composition without spending time managing layer naming conventions or updating a sprite sheet master. Maybe you’re a UI designer that have been forced to pick up someone else’s PSD, or a developer who’s been lumped with exporting the last retouches of an application after the designer went AWOL? If so, here’s a setup of a small Photoshop Action that you can use when you find yourself in these type of situations!
Creating the action
Open a PSD of you choice, create a new Action called “Single export” and hit “Record”. The first thing we’re going to do is to select a non-empty layer. I’ve selected the text layer “Example” as you can see in the image below.
Now, go to “Layer” in the menu and choose “Duplicate Layer…”. In the dialog, choose “Document: New”.
Now, the layer you chose to duplicate should open up in a new document (called something like “Untitled-1.psd”) that only contains your layer.
Go to “Image” in the menu and choose “Trim”. Set “Based on” to “Transparent Pixels” and activate all options for “Trim Away” (Top, Bottom, Left, Right).
Using Trim this way means that the size of your canvas will be trimmed to the same size as your layer based on its transparency information (including drop shadows, glows, strokes, etc.).
That’s it! Now you can stop recording the action (I’ve also committed it to a Function Key: F13 + Shift + Command). The action works for everything from multi-layer selection to groups. All that’s left now is setting the right preferences for saving (read more on that in this excellent article from Marc Edwards). This action does not in any way solve the bigger exporting questions, but it’s really good for those quick fixes we stumble upon on a daily basis.
If you’re lazy (like me), you can download the “Export single” action for Photoshop here which includes some extra steps for saving and closing down the automatically generated document that can be turned on and off in the Action panel.