Reputation: 2181
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?
Upvotes: 0
Views: 183
Reputation: 207345
The first line under Histogram
:
49602: ( 49, 51, 39) #313327 srgb(49,51,39)
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:
0: (121,131, 75) #79834B srgb(121,131,75)
That means that wherever the color srgb(121,131,75)
occurs in the image, we only store the palette index 0
at that location, rather than the colour 121,131,75
. That means we only use 1 byte to store a 0
instead 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):
magick -size 40x600 gradient: \( xc: +noise random \) +append -rotate 90 PNG24:a.png
And now do the same thing, but oblige ImageMagick to create a palette image (which comes out at 25kB):
magick -size 40x600 gradient: \( xc: +noise random \) +append -rotate 90 PNG8:a.png
There is a longer explanation with example here.
Upvotes: 2