Re: Average Color of JPG
Re: Average Color of JPG
- Subject: Re: Average Color of JPG
- From: Shane Stanley <email@hidden>
- Date: Sat, 19 Apr 2003 17:51:28 +1000
On 17/4/03 4:23 PM +1000, Graham Carter, email@hidden, wrote:
>
I am trying to get the average color of a .jpg. I found a photoshop
>
function "Fit Image..." under the file menu which you can reduce the
>
image down to 1x1 pixels. The one pixel remaining seems to be the
>
right color (an average of whole image). I cannot figure out how to
>
get that color however.
You could get the histogram of the R, G and B channels, and work it out from
there:
tell application "Adobe Photoshop 7.0"
tell current document
set {r, g, b} to histogram of channels 1 thru 3
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
--
Shane Stanley, email@hidden
_______________________________________________
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.