I use the identify command in the form below:
identify -verbose image.png
Part of the output is:
Colors: 8
Histogram:
49602: ( 49, 51, 39) #313327 srgb(49,51,39)
36492: ( 98,121,135) #627987 srgb(98,121,135)
21728: ( 98,182,240) #62B6F0 srgb(98,182,240)
39526: (121,131, 75) #79834B srgb(121,131,75)
34298: (165,171,147) #A5AB93 srgb(165,171,147)
29957: (185,200,226) #B9C8E2 srgb(185,200,226)
18767: (210,185, 67) #D2B943 srgb(210,185,67)
31774: (246, 69, 44) #F6452C srgb(246,69,44)
Colormap entries: 9
Colormap:
0: (121,131, 75) #79834B srgb(121,131,75)
1: ( 49, 51, 39) #313327 srgb(49,51,39)
2: (210,185, 67) #D2B943 srgb(210,185,67)
3: (165,171,147) #A5AB93 srgb(165,171,147)
4: (185,200,226) #B9C8E2 srgb(185,200,226)
5: ( 98,121,135) #627987 srgb(98,121,135)
6: ( 98,182,240) #62B6F0 srgb(98,182,240)
7: (246, 69, 44) #F6452C srgb(246,69,44)
8: (255,255,255) #FFFFFF white
I see that the same colors as in Histogram plus white, but in a different order appear also in the colormap.
What is the difference between the two?
The first line under
Histogram:tells you that there are 49,602 pixels in the image with the colour
sRGB(49,51,39). So it is telling you the frequency of occurrence, or how often, each colour occurs.The 9 lines under
Colormap:are the palette of the image.Let's look at the first line:
That means that wherever the color
srgb(121,131,75)occurs in the image, we only store the palette index0at that location, rather than the colour121,131,75. That means we only use 1 byte to store a0instead of storing 3 bytes of RGB, which means we save 2/3 of the space. It is a "LookUp Table" or palette.Palettes trade space for colour accuracy. In general, they are 1/3 of the size of the original image, but can normally only store 256 unique colours rather than the 16,777,216 colours of a conventional RGB image.
Just for fun, let's create this smooth greyscale gradient and some random noise as a conventional RGB888 image (which comes out at 75kB):
And now do the same thing, but oblige ImageMagick to create a palette image (which comes out at 25kB):
There is a longer explanation with example here.