Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Images hold often less colors than requested #90

Closed
frkay opened this issue May 3, 2014 · 6 comments
Closed

Images hold often less colors than requested #90

frkay opened this issue May 3, 2014 · 6 comments

Comments

@frkay
Copy link

frkay commented May 3, 2014

On various samples even when I ask for 256 colors in the resulting image I get less (down to 248 for some).
Files produced by pngquant apparently have 256 palette entries, but once optimized with pngrewrite, pngout or zopflipng the color count goes often down to 255 or 254 sometimes even less.
Here are some PNG-32 that trigger the problem (see next comment for steps to reproduce it).

sample_66
sample_56
sample_49
sample_24
sample_13
sample_10

@frkay
Copy link
Author

frkay commented May 3, 2014

I tried with the latest OS X binary (version 2.2.0), on the first image (the colored bubbles):

./pngquant-openmp --speed 1 fa88317a-d273-11e3-8371-48c11d194a81.png
./pngquant-openmp --nofs --speed 1 fa88317a-d273-11e3-8371-48c11d194a81.png

./pngrewrite fa88317a-d273-11e3-8371-48c11d194a81-or8.png fa88317a-or8rw.png
original palette size:   256,  8 bpp
Image size is 256x256  memory required=0.313MB
new palette size:        253,  8 bpp

./pngrewrite fa88317a-d273-11e3-8371-48c11d194a81-fs8.png fa88317a-fs8rw.png
original palette size:   256,  8 bpp
Image size is 256x256  memory required=0.313MB
new palette size:        253,  8 bpp

Both palettes sorted and shown side by side, the colors removed by pngrewrite were not in duplicate, I'll retrieve their original rank and look if they were really missing in the image body.

0x00,0x00,0x00,0x00    0x00,0x00,0x00,0x00
0x20,0xb4,0xe9,0xb3    0x20,0xb4,0xe9,0xb3
0x20,0xb5,0xe8,0xb0    0x20,0xb5,0xe8,0xb0
0x20,0xb5,0xe9,0xbc    0x20,0xb5,0xe9,0xbc
0x21,0xb6,0xe9,0x5e    0x21,0xb6,0xe9,0x5e
0x22,0xb6,0xe9,0xb3    0x22,0xb6,0xe9,0xb3
0x22,0xb7,0xea,0x72    0x22,0xb7,0xea,0x72
0x24,0xb6,0xe9,0x99    0x24,0xb6,0xe9,0x99
0x26,0xb8,0xe9,0xb3    0x26,0xb8,0xe9,0xb3
0x2a,0xba,0xea,0xb3    0x2a,0xba,0xea,0xb3
0x2c,0xbd,0xe9,0xb3    0x2c,0xbd,0xe9,0xb3
0x2f,0xbc,0xe4,0xbd    0x2f,0xbc,0xe4,0xbd
0x2f,0xbc,0xea,0x86    0x2f,0xbc,0xea,0x86
0x2f,0xbd,0xe9,0xb3    0x2f,0xbd,0xe9,0xb3
0x30,0xbd,0xea,0xb3    0x30,0xbd,0xea,0xb3
0x31,0xbc,0xe6,0x1e    0x31,0xbc,0xe6,0x1e
0x33,0xbf,0xea,0xb3    0x33,0xbf,0xea,0xb3
0x35,0xbc,0xe4,0x42    0x35,0xbc,0xe4,0x42
0x37,0x33,0x2c,0x01    0x37,0x33,0x2c,0x01
0x37,0xc1,0xeb,0xb3    0x37,0xc1,0xeb,0xb3
0x38,0xbf,0xe5,0x30    0x38,0xbf,0xe5,0x30
0x3a,0xc2,0xea,0xb3    0x3a,0xc2,0xea,0xb3
0x3b,0xc3,0xea,0xbc    0x3b,0xc3,0xea,0xbc
0x3b,0xc3,0xeb,0xb3    0x3b,0xc3,0xeb,0xb3
0x3e,0xc4,0xea,0xb3    0x3e,0xc4,0xea,0xb3
0x3e,0xc5,0xeb,0xb3    0x3e,0xc5,0xeb,0xb3
0x41,0xc5,0xe9,0x50    0x41,0xc5,0xe9,0x50
0x42,0xc7,0xea,0xb2    0x42,0xc7,0xea,0xb2
0x42,0xc8,0xeb,0xb3    0x42,0xc8,0xeb,0xb3
0x42,0xc8,0xec,0x98    0x42,0xc8,0xec,0x98
0x45,0xc8,0xeb,0xb3    0x45,0xc8,0xeb,0xb3
0x45,0xc8,0xed,0xb3    0x45,0xc8,0xed,0xb3
0x46,0xbe,0xce,0xd0    0x46,0xbe,0xce,0xd0
0x47,0xc9,0xe9,0xbc    0x47,0xc9,0xe9,0xbc
0x47,0xca,0xeb,0x77    0x47,0xca,0xeb,0x77
0x48,0xca,0xec,0xb3    0x48,0xca,0xec,0xb3
0x4b,0xcb,0xec,0xb3    0x4b,0xcb,0xec,0xb3
0x4b,0xcc,0xeb,0xaf    0x4b,0xcc,0xeb,0xaf
0x4b,0xce,0xed,0xb3    0x4b,0xce,0xed,0xb3
0x4f,0xce,0xec,0xb3    0x4f,0xce,0xec,0xb3
0x52,0xcd,0xec,0x68    0x52,0xcd,0xec,0x68
0x52,0xcf,0xed,0xb3    0x52,0xcf,0xed,0xb3
0x52,0xd2,0xed,0xb3    0x52,0xd2,0xed,0xb3
0x54,0xd4,0xeb,0xaf    0x54,0xd4,0xeb,0xaf
0x55,0xd1,0xed,0xb3    0x55,0xd1,0xed,0xb3
0x58,0xd3,0xed,0xbc    0x58,0xd3,0xed,0xbc
0x58,0xd6,0xef,0x87    0x58,0xd6,0xef,0x87
0x5a,0x67,0xcf,0x0f    0x5a,0x67,0xcf,0x0f
0x5a,0xc3,0xc5,0xe1    0x5a,0xc3,0xc5,0xe1
0x5a,0xd3,0xed,0xb3    0x5a,0xd3,0xed,0xb3
0x5c,0xc0,0xb4,0xff    0x5c,0xc0,0xb4,0xff
0x5c,0xc5,0xdf,0xc3    0x5c,0xc5,0xdf,0xc3
0x5e,0xbf,0xb9,0xf1    0x5e,0xbf,0xb9,0xf1
0x62,0xb7,0xd5,0xe1                       
0x62,0xbe,0xad,0xfe    0x62,0xbe,0xad,0xfe
0x63,0xb3,0xeb,0xd0    0x63,0xb3,0xeb,0xd0
0x63,0xc5,0xba,0xff    0x63,0xc5,0xba,0xff
0x64,0xc1,0xaf,0xff    0x64,0xc1,0xaf,0xff
0x66,0xc2,0xb1,0xff    0x66,0xc2,0xb1,0xff
0x66,0xcd,0xcf,0xde    0x66,0xcd,0xcf,0xde
0x69,0xc4,0xb3,0xff    0x69,0xc4,0xb3,0xff
0x6b,0xa3,0xea,0xe5    0x6b,0xa3,0xea,0xe5
0x6b,0xc6,0xb4,0xff    0x6b,0xc6,0xb4,0xff
0x6d,0xc3,0xa5,0xff    0x6d,0xc3,0xa5,0xff
0x6d,0xc7,0xb5,0xff    0x6d,0xc7,0xb5,0xff
0x6e,0xc8,0xb7,0xff    0x6e,0xc8,0xb7,0xff
0x6e,0xcc,0xc2,0xfc    0x6e,0xcc,0xc2,0xfc
0x6f,0x98,0xe8,0xf4    0x6f,0x98,0xe8,0xf4
0x6f,0xa0,0xe9,0xf5    0x6f,0xa0,0xe9,0xf5
0x70,0xc9,0xb8,0xff    0x70,0xc9,0xb8,0xff
0x71,0x9b,0xe9,0xf4    0x71,0x9b,0xe9,0xf4
0x71,0xc7,0xb2,0xff    0x71,0xc7,0xb2,0xff
0x72,0x9b,0xe6,0xf4    0x72,0x9b,0xe6,0xf4
0x72,0xa7,0xe7,0xf6    0x72,0xa7,0xe7,0xf6
0x72,0xca,0xb8,0xff    0x72,0xca,0xb8,0xff
0x72,0xca,0xb9,0xff    0x72,0xca,0xb9,0xff
0x74,0x9b,0xe8,0xf4    0x74,0x9b,0xe8,0xf4
0x74,0x9c,0xe7,0xf4    0x74,0x9c,0xe7,0xf4
0x74,0xcb,0xba,0xff    0x74,0xcb,0xba,0xff
0x74,0xcd,0xbb,0xff    0x74,0xcd,0xbb,0xff
0x75,0x9d,0xe7,0xf4    0x75,0x9d,0xe7,0xf4
0x75,0x9d,0xe9,0xf4    0x75,0x9d,0xe9,0xf4
0x75,0xd7,0xc1,0xff    0x75,0xd7,0xc1,0xff
0x76,0xce,0xbc,0xff    0x76,0xce,0xbc,0xff
0x76,0xd0,0xbe,0xff    0x76,0xd0,0xbe,0xff
0x79,0xd0,0xbe,0xff    0x79,0xd0,0xbe,0xff
0x79,0xd2,0xbe,0xff    0x79,0xd2,0xbe,0xff
0x7b,0x8d,0xe4,0xf0    0x7b,0x8d,0xe4,0xf0
0x7b,0xd2,0xc0,0xff    0x7b,0xd2,0xc0,0xff
0x7c,0xcc,0xbd,0xfe    0x7c,0xcc,0xbd,0xfe
0x7d,0xd4,0xc1,0xff    0x7d,0xd4,0xc1,0xff
0x7e,0x98,0xdc,0xf5    0x7e,0x98,0xdc,0xf5
0x7f,0xd5,0xc4,0xff    0x7f,0xd5,0xc4,0xff
0x81,0x00,0xc8,0xdb    0x81,0x00,0xc8,0xdb
0x82,0x79,0xe2,0xed    0x82,0x79,0xe2,0xed
0x83,0x00,0xc9,0x75    0x83,0x00,0xc9,0x75
0x84,0xcf,0xaa,0xff    0x84,0xcf,0xaa,0xff
0x85,0x00,0xc9,0x99    0x85,0x00,0xc9,0x99
0x85,0x00,0xc9,0xa7    0x85,0x00,0xc9,0xa7
0x85,0x00,0xc9,0xbd    0x85,0x00,0xc9,0xbd
0x85,0xc7,0x99,0xff    0x85,0xc7,0x99,0xff
0x87,0x00,0xca,0xd9    0x87,0x00,0xca,0xd9
0x87,0xc2,0xba,0xff    0x87,0xc2,0xba,0xff
0x88,0x61,0xe1,0xe9    0x88,0x61,0xe1,0xe9
0x89,0xb5,0xba,0xeb                       
0x8b,0x00,0xc4,0x29    0x8b,0x00,0xc4,0x29
0x8c,0x00,0xcd,0xd9    0x8c,0x00,0xcd,0xd9
0x90,0x00,0xcd,0x47    0x90,0x00,0xcd,0x47
0x90,0x00,0xcd,0xd3    0x90,0x00,0xcd,0xd3
0x91,0x00,0xcd,0xd9    0x91,0x00,0xcd,0xd9
0x91,0x49,0xde,0xe5    0x91,0x49,0xde,0xe5
0x92,0xb9,0xb7,0xff    0x92,0xb9,0xb7,0xff
0x94,0x00,0xcf,0xd9    0x94,0x00,0xcf,0xd9
0x97,0xa0,0xbc,0xcd    0x97,0xa0,0xbc,0xcd
0x98,0x00,0xd0,0xda    0x98,0x00,0xd0,0xda
0x98,0x92,0xc2,0xf7    0x98,0x92,0xc2,0xf7
0x99,0x00,0xd1,0x87    0x99,0x00,0xd1,0x87
0x9b,0x00,0xd1,0x61    0x9b,0x00,0xd1,0x61
0x9c,0x00,0xd0,0xd9    0x9c,0x00,0xd0,0xd9
0x9d,0x29,0xda,0xe0    0x9d,0x29,0xda,0xe0
0x9f,0x00,0xd3,0xda    0x9f,0x00,0xd3,0xda
0xa0,0x00,0xd3,0xb4    0xa0,0x00,0xd3,0xb4
0xa2,0xcb,0x79,0xff    0xa2,0xcb,0x79,0xff
0xa3,0x00,0xd4,0xd9    0xa3,0x00,0xd4,0xd9
0xa4,0xa6,0xb0,0xfd    0xa4,0xa6,0xb0,0xfd
0xa4,0xd3,0x8d,0xff    0xa4,0xd3,0x8d,0xff
0xa6,0x00,0xd5,0xd9    0xa6,0x00,0xd5,0xd9
0xaa,0x00,0xd7,0xe5    0xaa,0x00,0xd7,0xe5
0xaa,0x04,0xd1,0xd5    0xaa,0x04,0xd1,0xd5
0xab,0x00,0xd6,0xd9    0xab,0x00,0xd6,0xd9
0xb0,0x8e,0x76,0x07    0xb0,0x8e,0x76,0x07
0xb2,0x93,0x0f,0xa9    0xb2,0x93,0x0f,0xa9
0xb6,0x90,0xa8,0xfe    0xb6,0x90,0xa8,0xfe
0xb8,0x90,0xa6,0xdc    0xb8,0x90,0xa6,0xdc
0xbe,0x26,0xb4,0xe3    0xbe,0x26,0xb4,0xe3
0xc4,0x85,0xa0,0xf4    0xc4,0x85,0xa0,0xf4
0xc4,0xd5,0x6e,0xff    0xc4,0xd5,0x6e,0xff
0xc8,0x3a,0xa0,0xe8    0xc8,0x3a,0xa0,0xe8
0xce,0xcc,0x51,0xff    0xce,0xcc,0x51,0xff
0xd0,0x85,0x91,0xfd    0xd0,0x85,0x91,0xfd
0xd7,0x74,0x91,0xec    0xd7,0x74,0x91,0xec
0xda,0x61,0x80,0xf1    0xda,0x61,0x80,0xf1
0xdb,0x6f,0x9b,0xff    0xdb,0x6f,0x9b,0xff
0xe2,0xaf,0x6e,0xa2                       
0xe2,0xda,0x56,0xff    0xe2,0xda,0x56,0xff
0xe6,0xd0,0x38,0xff    0xe6,0xd0,0x38,0xff
0xe9,0x84,0x74,0xfe    0xe9,0x84,0x74,0xfe
0xe9,0x88,0x6e,0xfe    0xe9,0x88,0x6e,0xfe
0xea,0x87,0x70,0xf7    0xea,0x87,0x70,0xf7
0xeb,0x69,0x86,0xf8    0xeb,0x69,0x86,0xf8
0xeb,0x6e,0x84,0xf8    0xeb,0x6e,0x84,0xf8
0xeb,0x70,0x81,0xf8    0xeb,0x70,0x81,0xf8
0xeb,0x73,0x7f,0xf8    0xeb,0x73,0x7f,0xf8
0xeb,0x77,0x7c,0xf8    0xeb,0x77,0x7c,0xf8
0xeb,0x7a,0x7a,0xf9    0xeb,0x7a,0x7a,0xf9
0xeb,0x7e,0x77,0xfa    0xeb,0x7e,0x77,0xfa
0xeb,0x82,0x74,0xf8    0xeb,0x82,0x74,0xf8
0xec,0x68,0x8b,0xfe    0xec,0x68,0x8b,0xfe
0xed,0x62,0x93,0xff    0xed,0x62,0x93,0xff
0xed,0x64,0x8a,0xfe    0xed,0x64,0x8a,0xfe
0xed,0x64,0x90,0xff    0xed,0x64,0x90,0xff
0xed,0x70,0x86,0xff    0xed,0x70,0x86,0xff
0xee,0x5a,0x96,0xff    0xee,0x5a,0x96,0xff
0xee,0x5d,0x94,0xff    0xee,0x5d,0x94,0xff
0xee,0x5f,0x93,0xff    0xee,0x5f,0x93,0xff
0xee,0x67,0x8d,0xff    0xee,0x67,0x8d,0xff
0xee,0x6a,0x8b,0xff    0xee,0x6a,0x8b,0xff
0xee,0x6d,0x89,0xff    0xee,0x6d,0x89,0xff
0xee,0x81,0x68,0xfc    0xee,0x81,0x68,0xfc
0xef,0x8a,0x60,0xfb    0xef,0x8a,0x60,0xfb
0xf1,0xa0,0x46,0x13    0xf1,0xa0,0x46,0x13
0xf3,0x54,0x94,0xff    0xf3,0x54,0x94,0xff
0xf3,0x75,0x74,0xfa    0xf3,0x75,0x74,0xfa
0xf3,0xa1,0x4f,0x9b    0xf3,0xa1,0x4f,0x9b
0xf3,0xa7,0x4b,0xb3    0xf3,0xa7,0x4b,0xb3
0xf3,0xa8,0x4a,0xca    0xf3,0xa8,0x4a,0xca
0xf4,0x8d,0x5f,0xe6    0xf4,0x8d,0x5f,0xe6
0xf4,0x9a,0x54,0xe6    0xf4,0x9a,0x54,0xe6
0xf4,0x9d,0x52,0xe6    0xf4,0x9d,0x52,0xe6
0xf4,0xa1,0x4f,0xe6    0xf4,0xa1,0x4f,0xe6
0xf4,0xa3,0x4c,0x22    0xf4,0xa3,0x4c,0x22
0xf4,0xa3,0x4d,0x6e    0xf4,0xa3,0x4d,0x6e
0xf4,0xa6,0x4a,0xe6    0xf4,0xa6,0x4a,0xe6
0xf4,0xa6,0x4b,0xf1    0xf4,0xa6,0x4b,0xf1
0xf4,0xc5,0x33,0x34    0xf4,0xc5,0x33,0x34
0xf5,0x90,0x5c,0xe6    0xf5,0x90,0x5c,0xe6
0xf5,0x91,0x5b,0xc2    0xf5,0x91,0x5b,0xc2
0xf5,0x93,0x59,0xe6    0xf5,0x93,0x59,0xe6
0xf5,0x97,0x57,0xe6    0xf5,0x97,0x57,0xe6
0xf6,0x61,0x88,0xfd    0xf6,0x61,0x88,0xfd
0xf6,0x71,0x72,0x4a    0xf6,0x71,0x72,0x4a
0xf6,0x7f,0x68,0xe6    0xf6,0x7f,0x68,0xe6
0xf6,0x83,0x66,0xe6    0xf6,0x83,0x66,0xe6
0xf6,0x86,0x64,0xe6    0xf6,0x86,0x64,0xe6
0xf6,0x88,0x62,0xe6    0xf6,0x88,0x62,0xe6
0xf6,0x8b,0x60,0xe7    0xf6,0x8b,0x60,0xe7
0xf6,0xbf,0x34,0x4c    0xf6,0xbf,0x34,0x4c
0xf7,0x68,0x7d,0xf6    0xf7,0x68,0x7d,0xf6
0xf7,0x6f,0x74,0xe6    0xf7,0x6f,0x74,0xe6
0xf7,0x6f,0x75,0xab    0xf7,0x6f,0x75,0xab
0xf7,0x73,0x72,0xe6    0xf7,0x73,0x72,0xe6
0xf7,0x76,0x6f,0xe6    0xf7,0x76,0x6f,0xe6
0xf7,0x7a,0x6d,0xe6    0xf7,0x7a,0x6d,0xe6
0xf7,0x7d,0x6b,0xe6    0xf7,0x7d,0x6b,0xe6
0xf8,0x60,0x80,0xc6    0xf8,0x60,0x80,0xc6
0xf8,0x62,0x7f,0xe6    0xf8,0x62,0x7f,0xe6
0xf8,0x66,0x7c,0xe6    0xf8,0x66,0x7c,0xe6
0xf8,0x67,0x7a,0x7b    0xf8,0x67,0x7a,0x7b
0xf8,0x69,0x79,0xe6    0xf8,0x69,0x79,0xe6
0xf8,0x6d,0x76,0xe6    0xf8,0x6d,0x76,0xe6
0xf9,0x59,0x86,0xe5    0xf9,0x59,0x86,0xe5
0xf9,0x5a,0x84,0xf1    0xf9,0x5a,0x84,0xf1
0xf9,0x5d,0x82,0xe6    0xf9,0x5d,0x82,0xe6
0xf9,0xcc,0x1a,0xb6    0xf9,0xcc,0x1a,0xb6
0xf9,0xcd,0x19,0xfe    0xf9,0xcd,0x19,0xfe
0xf9,0xcd,0x1a,0xee    0xf9,0xcd,0x1a,0xee
0xf9,0xcf,0x1f,0xd9    0xf9,0xcf,0x1f,0xd9
0xf9,0xcf,0x1f,0xfe    0xf9,0xcf,0x1f,0xfe
0xf9,0xd5,0x2c,0xfc    0xf9,0xd5,0x2c,0xfc
0xf9,0xd5,0x2d,0x5c    0xf9,0xd5,0x2d,0x5c
0xf9,0xd5,0x2d,0x9b    0xf9,0xd5,0x2d,0x9b
0xf9,0xd5,0x2f,0x77    0xf9,0xd5,0x2f,0x77
0xf9,0xdc,0x3e,0xfd    0xf9,0xdc,0x3e,0xfd
0xfa,0x6f,0x80,0xff    0xfa,0x6f,0x80,0xff
0xfa,0xcf,0x1b,0xff    0xfa,0xcf,0x1b,0xff
0xfa,0xd1,0x20,0xff    0xfa,0xd1,0x20,0xff
0xfa,0xd2,0x23,0xff    0xfa,0xd2,0x23,0xff
0xfa,0xd3,0x27,0xff    0xfa,0xd3,0x27,0xff
0xfa,0xd5,0x2a,0xff    0xfa,0xd5,0x2a,0xff
0xfa,0xd9,0x38,0xfe    0xfa,0xd9,0x38,0xfe
0xfa,0xdf,0x48,0xfc    0xfa,0xdf,0x48,0xfc
0xfb,0x66,0x85,0xff    0xfb,0x66,0x85,0xff
0xfb,0x6a,0x83,0xff    0xfb,0x6a,0x83,0xff
0xfb,0xd6,0x2d,0xff    0xfb,0xd6,0x2d,0xff
0xfb,0xd8,0x30,0xff    0xfb,0xd8,0x30,0xff
0xfb,0xd9,0x33,0xff    0xfb,0xd9,0x33,0xff
0xfb,0xda,0x38,0xff    0xfb,0xda,0x38,0xff
0xfb,0xdd,0x3d,0xff    0xfb,0xdd,0x3d,0xff
0xfb,0xdf,0x41,0xff    0xfb,0xdf,0x41,0xff
0xfb,0xdf,0x42,0xb2    0xfb,0xdf,0x42,0xb2
0xfb,0xe1,0x4b,0xcf    0xfb,0xe1,0x4b,0xcf
0xfc,0x58,0x8b,0xff    0xfc,0x58,0x8b,0xff
0xfc,0x5f,0x89,0xff    0xfc,0x5f,0x89,0xff
0xfc,0x62,0x87,0xff    0xfc,0x62,0x87,0xff
0xfc,0x90,0x76,0xff    0xfc,0x90,0x76,0xff
0xfc,0xb8,0x68,0xff    0xfc,0xb8,0x68,0xff
0xfc,0xd2,0x5e,0xff    0xfc,0xd2,0x5e,0xff
0xfc,0xe0,0x44,0xff    0xfc,0xe0,0x44,0xff
0xfc,0xe1,0x48,0xff    0xfc,0xe1,0x48,0xff
0xfc,0xe3,0x4b,0xff    0xfc,0xe3,0x4b,0xff
0xfc,0xe4,0x4f,0xff    0xfc,0xe4,0x4f,0xff
0xfc,0xe4,0x55,0xfd    0xfc,0xe4,0x55,0xfd
0xfc,0xe5,0x52,0xff    0xfc,0xe5,0x52,0xff
0xfc,0xe7,0x57,0xff    0xfc,0xe7,0x57,0xff
0xfc,0xed,0x55,0xff    0xfc,0xed,0x55,0xff
0xff,0xd3,0x1d,0xff    0xff,0xd3,0x1d,0xff

(0x62,0xb7,0xd5,0xe1) was color #182
(0x89,0xb5,0xba,0xeb) was color #181
(0xe2,0xaf,0x6e,0xa2) was color #183

Based on Huffman header analysis of the PNG produced by pngquant (this works since there's only one Deflate block in the compressed stream and the sole PNG filter used is 0 -none-), these 3 colors are effectively never used in the image:

defdb -a fa88317a-d273-11e3-8371-48c11d194a81-or8.png
…
0xB3      2 11 11
0xB4      1 12 12
0xB5         .  .
0xB6         .  .
0xB7         .  .
0xB8     13  9  9
0xB9     18  8  8
…

The same colors are missing in the dithered version of this image:

defdb -a fa88317a-d273-11e3-8371-48c11d194a81-fs8.png
…
0xB3      2 12 12
0xB4      1 12 12
0xB5         .  .
0xB6         .  .
0xB7         .  .
0xB8      8 10 10
0xB9     15  9  9
…

@frkay
Copy link
Author

frkay commented May 3, 2014

Another test, this time using the Windows version of pngquant available on the main site (version 2.1.1) on the second image (Google logo).

pngquant --speed 1 fa95ea22-d273-11e3-89a0-05d1a3b4fccb.png
pngquant --nofs --speed 1 fa95ea22-d273-11e3-89a0-05d1a3b4fccb.png

pngrewrite fa95ea22-d273-11e3-89a0-05d1a3b4fccb-or8.png fa95ea22-or8rw.png
original palette size:   256,  8 bpp
Image size is 538x190  memory required=0.488MB
new palette size:        248,  8 bpp

pngrewrite fa95ea22-d273-11e3-89a0-05d1a3b4fccb-fs8.png fa95ea22-fs8rw.png
original palette size:   256,  8 bpp
Image size is 538x190  memory required=0.488MB
new palette size:        248,  8 bpp

This time pngrewrite removed 8 colors!
And defdb -a reports that the bytes (and therefore the associated colors in the palette) in the range 0x84...0x8b never appear in the image:

defdb -a fa95ea22-d273-11e3-89a0-05d1a3b4fccb-or8.png
…
0x82      1 12 12
0x83      1 12 12
0x84         .  .
0x85         .  .
0x86         .  .
0x87         .  .
0x88         .  .
0x89         .  .
0x8A         .  .
0x8B         .  .
0x8C     10  9  9
0x8D      8  9  9
…

On the third image (Donut box):

pngquant --nofs --speed 1 fa9afd6e-d273-11e3-9193-237a8beb417e.png

pngrewrite fa9afd6e-d273-11e3-9193-237a8beb417e-or8.png fa9afd6e-or8rw.png
original palette size:   256,  8 bpp
Image size is 118x112  memory required=0.063MB
new palette size:        249,  8 bpp


defdb -a fa9afd6e-d273-11e3-9193-237a8beb417e-or8.png
…
0x37      2 11 11
0x38      1 12 12
0x39         .  .
0x3A         .  .
0x3B         .  .
0x3C         .  .
0x3D         .  .
0x3E         .  .
0x3F     42  7  7
0x40     23  8  8
…
0xFD      2 11 11
0xFE      2 12 12
0xFF         .  .
EofB      1 12 12
l_00    323  4  4
l_01    214  4  4
…

Weird!?

@pdknsk
Copy link
Contributor

pdknsk commented May 4, 2014

It's an interesting bug. Some additional observations, on the Google image.

$ pngquant 256 --speed 1 -fv f.png
  mapped image to new colors...MSE=0.067 (Q=99)

$ pngquant 212 --speed 1 -fv f.png
  mapped image to new colors...MSE=0.098 (Q=99)

$ pngquant 210 --speed 1 -fv f.png
  mapped image to new colors...MSE=0.088 (Q=99)

@petrdiblik
Copy link

+1
I have been monitoring this bug for a long time, with many images.
It is still present in version 2.5.2.
Could that be fixed please?
(In my opinion, a basic fix would be excluding the unused colors from PLTE. An advanced fix would be using maximum colors (according to the ncolors parameter) in both PLTE and IDAT and thus getting even better output.)

@dsvensson
Copy link

dsvensson commented Jul 2, 2022

Noticed this as well. My use case is an image that's black and transparent and is converted from 256 bit to a 1 bit palette, the 3D engine that it's used in expects 256 bit palette so it breaks.

@kornelski
Copy link
Owner

I do not expect this to be an issue in v4.0.0. Please file a new bug with example images if you still find problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants