Re: Getting values in Photoshop 7 - the complete request
Re: Getting values in Photoshop 7 - the complete request
- Subject: Re: Getting values in Photoshop 7 - the complete request
- From: Paul Skinner <email@hidden>
- Date: Wed, 21 May 2003 13:06:19 -0400
On Tuesday, May 20, 2003, at 06:40 PM, Shane Stanley wrote:
To save the hunt, here's the RGB version; CMYK will involve the same
thing
but four channels:
tell application "Adobe Photoshop 7.0"
activate
tell current document
select region {{2, 3}, {2, 4}, {3, 4}, {3, 3}} without
antialiasing
s repeat with i from 1 to 256
if item i of r = 1 then
set thered to (i - 1)
end if
if item i of g = 1 then
set thegreen to (i - 1)
end if
if item i of b = 1 then
set theblue to (i - 1)
end if
end repeat
{thered, thegreen, theblue}
end tell
end tell
snip
--
Shane Stanley, email@hidden
Shane,
That's certainly a lot prettier than the javascript version that uses
the same technique. :^P
Here's my version.
This one works with any image mode* (RGB, CMYK, LAB, grayscale etc.)
that has component channels. It's about a half second faster (45%) OMM.
*Don't forget to convert the values to percentages for the
appropriate modes.
getPixelColor(1, 4)
-->{242, 125, 137}
on getPixelColor(x, y)
tell application "Adobe Photoshop 7.0"
set pixelColor to {}
tell current document
select region {{x - 1, y - 1}, {x, y - 1}, {x - 1, y}, {x, y}}
without antialiasing
set channelCount to count (get component channels)
set histogramList to histogram of channels 1 thru channelCount
end tell
end tell
set AppleScript's text item delimiters to ""
repeat with currentHistogram in histogramList
set the end of the pixelColor to the offset of "1" in
(currentHistogram as text)
end repeat
return pixelColor
end getPixelColor
Paul Skinner
"The Church says the Earth is flat. But I know the Earth is round, for
I have seen the shadow on the moon, and I have more faith in a shadow
than in the Church."
- Magellan
_______________________________________________
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.