There are two aspects to my answer:
- Resize the original image to a 1-pixel-image. This pixel then will have the "average" color as ImageMagick's
convert
sees it.
- Output the result as the special
.txt
format supported by convert
. This text format enumerates all pixels of an image, giving first its coordinates ($row,$column:
), then its RGB or CMYK values in different formats.
Here is a command which covers both aspects in one:
convert cat.png -resize 1x1 out.txt
cat out.txt
To get the output directly in the terminal window, you could use:
convert cat.png -resize 1x1 txt:-
Example output:
convert p4.png -resize 1x1 txt:-
# ImageMagick pixel enumeration: 1,1,255,srgb
0,0: (189,185,184) #BDB9B8 srgb(189,185,184)