Take the 2-minute tour ×
Graphic Design Stack Exchange is a question and answer site for Graphic Design professionals, students, and enthusiasts. It's 100% free, no registration required.

I'm wondering if there is a way to setup an Action in CS6 that would be able to determine the dimensions of an image or layer?

Ultimately, I'd like to create a watermark essentially which would stamp the image with its own dimensions.

Any help appreciated.

share|improve this question
add comment

1 Answer 1

up vote 5 down vote accepted

I'm not sure that an action is necessarily the best option for you. A script could do something like this fairly easily. This should give you some useful pointers as far as basic scripting goes..

Basically, the script has to do a few things. First, get the layer dimensions and save them as a variable. Then, make a new text layer, and use the variables as that text.

Below is the basic skeleton of the script:

function run(){
    var layer = activeDocument.activeLayer; //Grab the currently selected layer

    //Calculate length and width based on the rectangular bounds of the selected layer
    var length = layer.bounds[2]-layer.bounds[0]; //Grab the length
    var width = layer.bounds[3]-layer.bounds[1]; //Grab the width

    //Create a text layer
    var textLayer = activeDocument.artLayers.add(); //Make a new layer on the canvas
    textLayer.kind = LayerKind.TEXT; //Make that layer a text layer
    textLayer.name = "Dimensions"; //Name the layer "Dimensions"
    var textReference = textLayer.textItem; //Create a textItem which we'll use to fill the text layer
    textReference.contents = "Length: " + length + " Width: " + width; //Set the contents of that textItem to the length and width

}
run();

You can run this by copying and pasting this code into a file named "dimensions.jsx", then going to File->Scripts->Browse and navigating to that script.

Below is "proof" that this works - I created a new layer named Layer 1, and selected it. In the "Info" panel, you can see the length and width listed. I then ran the script, which created a new layer named Dimensions, whose text contents are the same length and width presented in the Info panel (without the rounding). Proof

Let me know if you have any other questions!

share|improve this answer
    
Interesting. I wasn't aware of scripts. I guess I would still be able to create a droplet using the script? –  skube Sep 11 '13 at 22:35
    
What exactly is the end-goal here? You certainly could make an action/droplet that runs the script. You could also program the script to ask you for a folder, so that when you select the folder, the script is run on every image in that folder (there are code tutorials online to get that to work, although I don't know how much programming experience you have). –  user774359 Sep 11 '13 at 22:51
    
The end goal is to easily watermark any image (any dimension, any file type) with its own dimensions. –  skube Sep 12 '13 at 13:39
    
Ok, then yes with this simple script installed (adobe.com/devnet/photoshop/scripting.html, look in the CS6 section for the Script Listener plugin), you should be able to go to File->Scripts and choose the installed script, thus watermarking that image with its dimensions. As long as Photoshop can open the image (any file type), it should work just fine. You can also create a droplet/action that runs the script if that's easier for you to access. –  user774359 Sep 12 '13 at 14:43
    
Thank you very much! –  skube Sep 12 '13 at 16:29
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.