Getting average image color from Python

It's quite common to see web pages that show a solid color in place of images, while resources are being loaded. The color is usually averaged from the original image, as to give it a more "consistent" feeling while the page loads.

A simple way to do this from the command line is by using ImageMagick to resize the image to 1x1 size, then get the color of that one pixel:

% convert pic.jpg -resize '1x1!' txt:-
# ImageMagick pixel enumeration: 1,1,65535,srgb
0,0: (16818.3,27417.8,39342.8)  #416B99  srgb(65,107,153)

(The image ...

Page 1 / 1