Home
upgrade flash

Photoshop Scripts #1

Working in Photoshop over time, I came up with a few scripts to make my work easier. I’ve attached them all here in case other people can use them or at least learn from them – personally, examples helped me the most while learning how to code scripts.

Most of these I have assigned to keyboard shortcuts which really speeds things up.
Enjoy!

Cut the image into tiles defined by the guides. The code first reads all the guidelines in the document, then duplicates it, merges all the visible layers and crops the image to match the first tile. Once the file is saved, the duplicate document is closed without saving and a new copy is made for the next tile and so on.

Click here to see the actual code

This script helps generate all the required sizes that Apple needs for the Appstore submission of any app. The code duplicates the document, flattens it, crops it to the right size (with the anchor in the center of the image) and then saves the file. Repeat for all screenshots. This script requires a certain specific size of the original document, so that enough information is available and no actual resampling takes place.

Click here to see the actual code

Pretty much the same as above, only this time the script generates all the launch images for an app (all aspect ratios and sizes that Apple requires) and it also rotates the images to make sure the correct orientation is achieved.

Click here to see the actual code

At some point I had to work on several documents that required me to add a huge number of guides in specific places. Unfortunately, there’s no command in PS to add a guide where the mouse is, so I couldn’t create an action. Even worse, there no way to expose the mouse position and actually insert a guide when a key is pressed via script. So my workaround was to insert horizontal guides at the top and bottom coordinates of a selection. This turned out to be even better, as I can adjust the selection while I’m making it and then, at the press of a button, I can create 2 guides at once.

Click here to see the actual code

Same as above, only this time the script generates vertical guides at the left and right edges of the selection.

Click here to see the actual code

When creating images for iOS apps, you need to make sure you create both retina (@2x) assets (even @3x recently) and normal sized ones for non-retina devices. Obviously this means creating the assets @2x to start with and resizing down. However, not all assets have an even number of pixels as their height, so this script checks that and adds a 1px row if the height is odd-numbered. Then the script is used as part of an batch of actions (cut, resize, save as etc). I’ve used add 1 row since my assets had a transparent background. However, if yours have a full background, I recommend using -1 pixels at the bottom instead of +1.

Click here to see the actual code

I made this script while working with multiple groups containing animation frames inside. Often I would need to have just one of the frames visible (and the PS way of ALT+click on the eye of the layer doesn’t work, because it renders all the other groups and layers in the document invisible, which is not what I wanted). So this script lets you make all the layers inside a group invisible, except the selected one. After that, since it’s a toggle script, just select one of the invisible layers inside the group and run the script again to turn them all on again.

Click here to see the actual code

Leave a Reply