I’m working on a Photoshop script that will generate a block of text at the top of a new document that will wrap over multiple lines, then place an image directly 36 pixels below it. What I can’t figure out is how to get Applescript/Photoshop to tell me how tall the wrapped lines of text are. This is a batch job, so in some cases, the text block will be short, but in others it might be several lines longer.
So I get the concept of the ‘paragraph text’ kind of text object that will wrap text blocks, but I can’t figure out how to place the image the exact spot below. Here’s the text part of my code:
tell application "Adobe Photoshop CS3"
set doc to make new document with properties {width:500, height:500}
set textLayer to make new art layer of doc with properties {kind:text layer}
set kind of text object of textLayer to paragraph text
set font of text object of textLayer to "Helvetica"
set size of text object of textLayer to 21
set width of text object of textLayer to 500
set height of text object of textLayer to 200
set position of text object of textLayer to {0, 0}
set contents of text object of textLayer to "This is the block of text that will change length."
end tell
Im not at my work mac at the moment but you should be able to use the “with placing” option from the “open” command in CS3&4 or something to that effect. Script listener is only required with CS2. You may be able to get the height/depth of your type contents by getting the bounds of the text layer.
Stefan, I don’t have it so I could not say for sure I thought it was CS3 may be its CS4.
get bounds of textLayer
should be enough to get the height in pixels
This is from the CS3 AppleScript Guide. I can’t test so I don’t know how this works. As of CS3 you can get an Extended Version of Photoshop with additional scripting features too. But this looks like it belongs to the standard version.
open: Includes a boolean parameter smart object, which indicates whether to create a smart object around the document opened.