Re: Photoshop: Get the height/width of a text layer?
Re: Photoshop: Get the height/width of a text layer?
- Subject: Re: Photoshop: Get the height/width of a text layer?
- From: Kenton Muschenheim <email@hidden>
- Date: Thu, 27 Feb 2003 15:39:34 -0600
Duane:
Your workaround sounds almost as convoluted as mine, which involves two
Photoshop actions and one mouse click of user intervention!! I'll try yours,
mine below. Anybody from Adobe listening!?!
---------------------------------------------------------------------------
tell application "Adobe Photoshop 7.0"
activate
set docRef1 to current document
set ruler units of settings to inch units
set type units of settings to point units
set point size of settings to postscript size
make new art layer at beginning of docRef1 with properties {name:"Text",
kind:text layer}
set artLayerList to get every art layer of docRef1
repeat with layerRef in artLayerList
set current layer of docRef1 to layerRef
if (kind of layerRef is text layer) then
set textItemRef to text object of layerRef
set size of textItemRef to 6 as points
set font of textItemRef to "GillSans"
set text direction of textItemRef to horizontal
set contents of contents of textItemRef to "This is where I put
my text"
set stroke color of textItemRef to {class:RGB color, red:255.0,
green:255.0, blue:255.0}
set kind of textItemRef to paragraph text
set position of textItemRef to {0, 0}
end if
end repeat
set current layer of current document to layer "Text" of current
document
do action "1" from "1"
--Rasterize current layer Item: text
--Set Selection To: all
--Cut Selection To: 0 inches, 0 inches
--Copy
--Make New: document
--And then I have to press the "OK" button manually!!
set docRef2 to current document
set ruler units of settings to inch units
set theight to height of docRef2
set twidth to width of docRef2
close current document saving no
do action "2" from "1"
--Set Selection To: none
set vheight to height of current document
set vwidth to width of current document
set vheightRef to (vheight - (theight + 0.035))
set vwidthRef to (vwidth - (twidth + 0.045))
set layerRef to layer 1 of current document
translate layerRef delta x vwidthRef delta y vheightRef
end tell
----------------------------------------------------------------------------
>
From: "Duane L. Mitchell" <email@hidden>
>
Date: Thu, 27 Feb 2003 16:14:29 -0500
>
To: AppleScript Users <email@hidden>
>
Subject: Re: Photoshop: Get the height/width of a text layer?
>
>
AFAIK, you can't get the height and width properties of text unless you set
>
it to "paragraph text" in your script after creating it. Even then you can't
>
get the *exact* height and width of the text because setting it to paragraph
>
text enlarges the box. Here's what I've done as a work around.
>
>
Create the text layer and then move the text box to a known location. I use
>
{108,108} for my purposes. At the point the position of the text is
>
referenced by the bottom left corner of the box. Now convert it to paragraph
>
text. If you get the position of the text now it will reference the top left
>
x,y coordinates. Since you originally knew the y location to begin with you
>
can now subtract the new y from the original y. Now you know the exact
>
height of the text, not the box.
>
>
If you are stepping through your script you should notice that when convert
>
the text to paragraph text it enlarges both the height and width of the box.
>
?? Oh well. You can now get the height and width properties but, again, that
>
is of the box, not the text, the box has been enlarged beyond the text
>
dimensions. At this point I set the text to fully justified. Now I know that
>
the text will be forced to fill the box. This puts more space between
>
characters but...if you have a better idea, let me know. So now I can get
>
the exact width of the box.
>
>
Now you know the x,y of the top left corner, the exact height of the type,
>
and the exact width of the type. After that you can move it to wherever you
>
need it.
>
>
One more thing. You will need to make sure that Unit Prefeneces are in
>
points for Ruler, Type and Screen Resolution is set to 72 ppi. You need this
>
for your calculations. I made this a part of my script by making this an
>
Action called at the start of the script. I couldn't see any other way to do
>
it.
>
>
>
-Duane
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
Duane L. Mitchell
>
Next Generation Solutions
>
31 Granby Road Worcester, MA 01604-1643
>
email@hidden 508-792-4396
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
>
> How on earth do I this? I need to know the exact dimensions of the text
>
> layer so I can accurately place it in the right place in my document
>
>
>
> This does not work (after I rasterize the text):
>
>
>
> set textheight to height of current layer
>
> set textwidth to width of current layer
>
>
>
> Neither does this (after I rasterize the text and turn it into a selection):
>
>
>
> set textheight to height of current selection
>
> set textwidth to width of current selection
>
>
>
> Help!
>
> _______________________________________________
>
> applescript-users mailing list | email@hidden
>
> Help/Unsubscribe/Archives:
>
> http://www.lists.apple.com/mailman/listinfo/applescript-users
>
> Do not post admin requests to the list. They will be ignored.
>
_______________________________________________
>
applescript-users mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/applescript-users
>
Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.