PS Scripting Q
mercphoto
Registered Users Posts: 4,550 Major grins
Have a scripting question for Photo Shop CS. I'm trying to add a text box for a copyright notice. I can get the text box up, with text. But I can't seem to control where the box goes. How can I get my scrip to locate the box where I want it to be?
Apple Script examples are nice, but I'll take VB or Java and translate myself.
Apple Script examples are nice, but I'll take VB or Java and translate myself.
Bill Jurasz - Mercury Photography - Cedar Park, TX
A former sports shooter
Follow me at: https://www.flickr.com/photos/bjurasz/
My Etsy store: https://www.etsy.com/shop/mercphoto?ref=hdr_shop_menu
A former sports shooter
Follow me at: https://www.flickr.com/photos/bjurasz/
My Etsy store: https://www.etsy.com/shop/mercphoto?ref=hdr_shop_menu
0
Comments
I'm not sure what you mean by a text box. Which if any of the following do you mean?
- A dialog with text inside it
- A text box (called an EditText element in Java Script) inside a dialog
- A rectangular area in a photoshop image into which you place text
There is an example in the Photoshop CS Java Script Reference Guide (page 21 of the PDF) that shows how to position a dialog box and how to position an EditText element.Dialog
The parameters that specify the dialog's location (and size) are highlighted.
Text Box Control (EditText Element)
The parameters that specify the edittext element's location (and size) are highlighted.
I'll try to come up with an example of how to position a rectangular area in a photoshop image.
Oh, and by the way...
Welcome to dgrin!
The values used to define the selection region are in pixels.
Hutch
If mercphoto was trying to go for a look like this
The benefit of positioning the text (and box) in a script is that it doesn't require user intervention.
First, thanks for all the replies. Yes, I can use the hand tool to move it manually, but the point of the script is I want this placed AUTOMATICALLY.
I'm pasting in part of my script. I'm trying to take an 8x12 image, reduce the image to 6x9, make the canvas 8x10, then put an art layer as a text object below the image for a copyright notice. I can figure out everything except how to position the text object where I want it to be.
set isLandscape to true
set x_image to 9
set y_image to 6
set x_canvas to 10
set y_canvas to 8
tell application "Adobe Photoshop CS"
set ruler units of settings to inch units
set type units of settings to point units
set point size of settings to postscript size
set documentCount to count every document
set counter to 0
repeat with counter from 1 to documentCount
set current document to document counter
set x to width of current document as inches
set y to height of current document as inches
-- we have an image, must be 8x12 or 12x8
-- if not, exit
if (y > 8) then
-- we have a portrait picture
set isLandscape to false
set x_image to 6
set y_image to 9
set x_canvas to 8
set y_canvas to 10
set y_text to 9.2
set textWidth to 6
end if
-- Set text box to be .25" below image, centered. Width of
-- text box is width of image. Box is 1" from left side
set x_text to 1
set y_text to y_image + (0.75 * (y_canvas - y_image))
set textWidth to x_image
resize image current document width x_image height y_image
resize canvas current document width x_canvas height y_canvas
set textLayer to make new art layer in current document with properties {kind:text layer}
set size of text object of textLayer to 12
set justification of text object of textLayer to center
set contents of text object of textLayer to "Copyright (c) 2004 Bill Jurasz, mercphoto.smugmug.com"
-- set width of text object of textLayer to textWidth
end repeat
end tell
A former sports shooter
Follow me at: https://www.flickr.com/photos/bjurasz/
My Etsy store: https://www.etsy.com/shop/mercphoto?ref=hdr_shop_menu
Have you tried this?
Yes, and that partially works. It is located correctly in the veritical direction (i.e under the photo), but not horizontally. Its also not centered, because the text layer is only as wide as the text itself.
Also I tried to do a "set width of text object of textLayer to 9" only to get an error that the fuction only applies to "paragraph text". Not sure what that means, but could shed additional light on the problem.
A former sports shooter
Follow me at: https://www.flickr.com/photos/bjurasz/
My Etsy store: https://www.etsy.com/shop/mercphoto?ref=hdr_shop_menu
Not sure why, but this works. I think the secret was the x-location being the dead-center horizontally, and then center justify. The location seems to be bound to the justification point.
Thanks for all the clues! It pointed me in the right direction.
set x_text to x_canvas / 2
set y_text to y_image + (0.75 * (y_canvas - y_image))
set textWidth to x_image
resize image current document width x_image height y_image
resize canvas current document width x_canvas height y_canvas
set textLayer to make new art layer in current document with properties {kind:text layer}
set size of text object of textLayer to 12
set justification of text object of textLayer to center
set position of text object of textLayer to {x_text, y_text}
set contents of text object of textLayer to "Copyright (c) 2004 Bill Jurasz, mercphoto.smugmug.com"
A former sports shooter
Follow me at: https://www.flickr.com/photos/bjurasz/
My Etsy store: https://www.etsy.com/shop/mercphoto?ref=hdr_shop_menu