[magick-users] taking an average pixel color
Anthony Thyssen
anthony at griffith.edu.au
Wed Feb 9 19:10:02 PST 2005
"Mark D. Kahn" on wrote...
| I have a 100x100 px image that I need to get the average color from.
| Any ideas on how to do this?
|
| Thanks,
| -Mark
Simple.. resize the image to a single pixel, then read the color.
It is not perfect, but close enough for most needs.
convert image.png -resize 1x1 txt:-
# ImageMagick pixel enumeration: 1,1,255,RGB
0,0: (185,187,214) #B9BBD6
If you want to use that color as a background you can then use -fx to
map the color.
I did this in my example pages as part of automatically working out an
average color of a background pattern over which a GIF image was to be
overlayed...
http://www.cit.gu.edu.au/~anthony/graphics/imagick6/formats/#bg_pattern
Anthony Thyssen ( System Programmer ) <A.Thyssen at griffith.edu.au>
-----------------------------------------------------------------------------
"Brigadier, a straight line may be the shortest distance between two points,
but it is by no means the most interesting."
-- Doctor Who, "The Time Warrior"
-----------------------------------------------------------------------------
Anthony's Home is his Castle http://www.cit.gu.edu.au/~anthony/
Anthony Thyssen ( System Programmer ) <A.Thyssen at griffith.edu.au>
-----------------------------------------------------------------------------
Dr Who: "Aren't you going to say it's bigger on the inside than on
the outside? Everyone else does."
Colonel: "Why I should have thought that was quite obvious."
-----------------------------------------------------------------------------
Anthony's Home is his Castle http://www.cit.gu.edu.au/~anthony/
More information about the Magick-users
mailing list