Paulo Ney
Paulo Ney

Reputation: 111

How ImageMagic determines the ColorSpace of a PNG?

Suppose I create a simple PNG with:

convert -size 1x1 canvas:red red.png

Here is a similar image (bigger size) for reference:

enter image description here

Then run the command identify on it. It tells me the ColorSpace of the image is sRGB but there seems to be NO indication of this inside the file. In fact running

$ hexdump -C red.png 
00000000  89 50 4e 47 0d 0a 1a 0a  00 00 00 0d 49 48 44 52  |.PNG........IHDR|
00000010  00 00 00 01 00 00 00 01  01 03 00 00 00 25 db 56  |.............%.V|
00000020  ca 00 00 00 04 67 41 4d  41 00 00 b1 8f 0b fc 61  |.....gAMA......a|
00000030  05 00 00 00 20 63 48 52  4d 00 00 7a 26 00 00 80  |.... cHRM..z&...|
00000040  84 00 00 fa 00 00 00 80  e8 00 00 75 30 00 00 ea  |...........u0...|
00000050  60 00 00 3a 98 00 00 17  70 9c ba 51 3c 00 00 00  |`..:....p..Q<...|
00000060  06 50 4c 54 45 ff 00 00  ff ff ff 41 1d 34 11 00  |.PLTE......A.4..|
00000070  00 00 01 62 4b 47 44 01  ff 02 2d de 00 00 00 07  |...bKGD...-.....|
00000080  74 49 4d 45 07 e5 01 0d  17 04 37 80 ef 04 02 00  |tIME......7.....|
00000090  00 00 0a 49 44 41 54 08  d7 63 60 00 00 00 02 00  |...IDAT..c`.....|
000000a0  01 e2 21 bc 33 00 00 00  25 74 45 58 74 64 61 74  |..!.3...%tEXtdat|
000000b0  65 3a 63 72 65 61 74 65  00 32 30 32 31 2d 30 31  |e:create.2021-01|
000000c0  2d 31 33 54 32 33 3a 30  34 3a 35 35 2b 30 30 3a  |-13T23:04:55+00:|
000000d0  30 30 2d af d4 01 00 00  00 25 74 45 58 74 64 61  |00-......%tEXtda|
000000e0  74 65 3a 6d 6f 64 69 66  79 00 32 30 32 31 2d 30  |te:modify.2021-0|
000000f0  31 2d 31 33 54 32 33 3a  30 34 3a 35 35 2b 30 30  |1-13T23:04:55+00|
00000100  3a 30 30 5c f2 6c bd 00  00 00 00 49 45 4e 44 ae  |:00\.l.....IEND.|
00000110  42 60 82                                          |B`.|
00000113

does not provide a clue, that I know of.

I understand that identifying the ColorSpace of an image, that does not contain that information, is a very hard problem -- see one proposed solution looking at the histogram of colors here.

So how identify, from the ImageMagick suite, determines the ColorSpace of this image?

Upvotes: 0

Views: 869

Answers (2)

This is just a bug in ImageMagick. You can use exiftool to check whether sRGB + intent chunk is present. In this case, no.

Gamma 2.2 is not sRGB. Thus ImageMagic is wrong here. That is a common problem on Wikipedia, all SVG images when converted to PNG have this and it destroys the colours. See: https://phabricator.wikimedia.org/T26768

We will have to reencode all images on Wikipedia, since we use ImageMagick. Sigh.

Upvotes: 0

Kel Solaar
Kel Solaar

Reputation: 4070

It is common, but not standardized to assume that an image without an embedded or sidecar ICC profile or without an explicit encoding description is encoded according to IEC 61966-2-1:1999, i.e. sRGB specification.

Upvotes: 1

Related Questions