• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Average Color of JPG
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Average Color of JPG (From: Graham Carter <email@hidden>)

  • Prev by Date: Re: Strings comparisons over 32K
  • Next by Date: Re: Strings comparisons over 32K
  • Previous by thread: Average Color of JPG
  • Next by thread: Mail.app - Checking if an email was sent
  • Index(es):
    • Date
    • Thread