cannot create png with color-type=4 directly.
Posted: 2019-07-04T19:11:44-07:00
I tried with 7.0.8-51 Q16 x64 HDRI on Windows command line, and 7.0.8-50 Q16 x86_64 HDRI on msys2. (Both are on Windows 7 64 bit.)
For example,
create Gray+Alpha tiff.
As you see, Samples per pixel is 2 and all pixles are gray with alpha.
However
Output is indexed. So I tried:
-define png:color-type=6 works, but in this case image is gray (with alpha), so color-type=4 should work.
color-type=2 works but it lost transparency.
Note that I can create the file by passing tiff.
For example,
Code: Select all
$ magick logo: \( +clone -negate -colorspace HSV -separate -delete 0,1 \) -compose copy_opacity -composite -type GrayScaleAlpha x.tif
Code: Select all
$ tiffinfo.exe x.tif
TIFF Directory at offset 0xd060 (53344)
Image Width: 640 Image Length: 480
Bits/Sample: 8
Compression Scheme: LZW
Photometric Interpretation: min-is-black
Extra Samples: 1<unassoc-alpha>
FillOrder: msb-to-lsb
Orientation: row 0 top, col 0 lhs
Samples/Pixel: 2
Rows/Strip: 480
Planar Configuration: single image plane
Page Number: 0-1
Predictor: horizontal differencing 2 (0x2)
Code: Select all
$ magick x.tif -format '%c' histogram:info:-
7150: ( 6, 6, 6,251) #060606FB graya(6,0.984314)
136: ( 9, 9, 9,249) #090909F9 graya(9,0.976471)
111: ( 10, 10, 10,249) #0A0A0AF9 graya(10,0.976471)
55: ( 11, 11, 11,245) #0B0B0BF5 graya(11,0.960784)
88: ( 13, 13, 13,245) #0D0D0DF5 graya(13,0.960784)
68: ( 13, 13, 13,246) #0D0D0DF6 graya(13,0.964706)
120: ( 14, 14, 14,246) #0E0E0EF6 graya(14,0.964706)
97: ( 17, 17, 17,244) #111111F4 graya(17,0.956863)
35: ( 17, 17, 17,242) #111111F2 graya(17,0.94902)
83: ( 18, 18, 18,243) #121212F3 graya(18,0.952941)
67: ( 18, 18, 18,240) #121212F0 graya(18,0.941176)
130: ( 20, 20, 20,242) #141414F2 graya(20,0.94902)
270: ( 22, 22, 22,235) #161616EB graya(22,0.921569)
23: ( 22, 22, 22,242) #161616F2 graya(22,0.94902)
50: ( 23, 23, 23,242) #171717F2 graya(23,0.94902)
84: ( 25, 25, 25,236) #191919EC graya(25,0.92549)
98: ( 26, 26, 26,241) #1A1A1AF1 graya(26,0.945098)
25: ( 26, 26, 26,231) #1A1A1AE7 graya(26,0.905882)
50: ( 27, 27, 27,236) #1B1B1BEC graya(27,0.92549)
25: ( 28, 28, 28,242) #1C1C1CF2 graya(28,0.94902)
83: ( 30, 30, 30,229) #1E1E1EE5 graya(30,0.898039)
61: ( 30, 30, 30,237) #1E1E1EED graya(30,0.929412)
110: ( 31, 31, 31,243) #1F1F1FF3 graya(31,0.952941)
25: ( 32, 32, 32,225) #202020E1 graya(32,0.882353)
79: ( 34, 34, 34,225) #222222E1 graya(34,0.882353)
32: ( 34, 34, 34,238) #222222EE graya(34,0.933333)
106: ( 35, 35, 35,235) #232323EB graya(35,0.921569)
21: ( 36, 36, 36,239) #242424EF graya(36,0.937255)
2538: ( 37, 37, 37,223) #252525DF graya(37,0.87451)
176: ( 37, 37, 37,220) #252525DC graya(37,0.862745)
48: ( 38, 38, 38,230) #262626E6 graya(38,0.901961)
539: ( 39, 39, 39,221) #272727DD graya(39,0.866667)
80: ( 39, 39, 39,231) #272727E7 graya(39,0.905882)
31: ( 40, 40, 40,237) #282828ED graya(40,0.929412)
36: ( 41, 41, 41,232) #292929E8 graya(41,0.909804)
500: ( 43, 43, 43,219) #2B2B2BDB graya(43,0.858824)
38: ( 43, 43, 43,214) #2B2B2BD6 graya(43,0.839216)
86: ( 45, 45, 45,230) #2D2D2DE6 graya(45,0.901961)
30: ( 45, 45, 45,220) #2D2D2DDC graya(45,0.862745)
379: ( 46, 46, 46,218) #2E2E2EDA graya(46,0.854902)
28: ( 46, 46, 46,233) #2E2E2EE9 graya(46,0.913725)
21: ( 46, 46, 46,231) #2E2E2EE7 graya(46,0.905882)
54: ( 47, 47, 47,224) #2F2F2FE0 graya(47,0.878431)
40: ( 47, 47, 47,238) #2F2F2FEE graya(47,0.933333)
32: ( 47, 47, 47,213) #2F2F2FD5 graya(47,0.835294)
98: ( 48, 48, 48,228) #303030E4 graya(48,0.894118)
37: ( 48, 48, 48,209) #303030D1 graya(48,0.819608)
558: ( 49, 49, 49,217) #313131D9 graya(49,0.85098)
24: ( 50, 50, 50,213) #323232D5 graya(50,0.835294)
3: ( 50, 50, 50,224) #323232E0 graya(50,0.878431)
422: ( 51, 51, 51,216) #333333D8 graya(51,0.847059)
85: ( 52, 52, 52,227) #343434E3 graya(52,0.890196)
228: ( 53, 53, 53,216) #353535D8 graya(53,0.847059)
163: ( 53, 53, 53,204) #353535CC graya(53,0.8)
37: ( 53, 53, 53,229) #353535E5 graya(53,0.898039)
2942: ( 54, 54, 54,255) #363636FF graya(54,1)
17: ( 54, 54, 54,232) #363636E8 graya(54,0.909804)
142: ( 55, 55, 55,225) #373737E1 graya(55,0.882353)
412: ( 56, 56, 56,217) #383838D9 graya(56,0.85098)
32: ( 57, 57, 57,202) #393939CA graya(57,0.792157)
23: ( 57, 57, 57,218) #393939DA graya(57,0.854902)
19: ( 57, 57, 57,230) #393939E6 graya(57,0.901961)
405: ( 58, 58, 58,217) #3A3A3AD9 graya(58,0.85098)
25: ( 59, 59, 59,203) #3B3B3BCB graya(59,0.796078)
21: ( 59, 59, 59,198) #3B3B3BC6 graya(59,0.776471)
337: ( 60, 60, 60,219) #3C3C3CDB graya(60,0.858824)
27: ( 61, 61, 61,225) #3D3D3DE1 graya(61,0.882353)
12466: ( 62, 62, 62,221) #3E3E3EDD graya(62,0.866667)
7: ( 62, 62, 62,201) #3E3E3EC9 graya(62,0.788235)
22: ( 63, 63, 63,197) #3F3F3FC5 graya(63,0.772549)
41: ( 65, 65, 65,192) #414141C0 graya(65,0.752941)
41: ( 65, 65, 65,235) #414141EB graya(65,0.921569)
19: ( 66, 66, 66,223) #424242DF graya(66,0.87451)
118: ( 67, 67, 67,239) #434343EF graya(67,0.937255)
57: ( 67, 67, 67,212) #434343D4 graya(67,0.831373)
17: ( 67, 67, 67,224) #434343E0 graya(67,0.878431)
14: ( 67, 67, 67,225) #434343E1 graya(67,0.882353)
14: ( 67, 67, 67,233) #434343E9 graya(67,0.913725)
11: ( 67, 67, 67,223) #434343DF graya(67,0.87451)
118: ( 69, 69, 69,223) #454545DF graya(69,0.87451)
804: ( 70, 70, 70,186) #464646BA graya(70,0.729412)
11: ( 71, 71, 71,204) #474747CC graya(71,0.8)
11: ( 71, 71, 71,223) #474747DF graya(71,0.87451)
199: ( 72, 72, 72,208) #484848D0 graya(72,0.815686)
9: ( 72, 72, 72,200) #484848C8 graya(72,0.784314)
67: ( 73, 73, 73,184) #494949B8 graya(73,0.721569)
206: ( 75, 75, 75,224) #4B4B4BE0 graya(75,0.878431)
73: ( 75, 75, 75,180) #4B4B4BB4 graya(75,0.705882)
51: ( 76, 76, 76,182) #4C4C4CB6 graya(76,0.713725)
34: ( 77, 77, 77,206) #4D4D4DCE graya(77,0.807843)
95: ( 79, 79, 79,223) #4F4F4FDF graya(79,0.87451)
8: ( 80, 80, 80,213) #505050D5 graya(80,0.835294)
9: ( 82, 82, 82,228) #525252E4 graya(82,0.894118)
33: ( 83, 83, 83,195) #535353C3 graya(83,0.764706)
24: ( 83, 83, 83,176) #535353B0 graya(83,0.690196)
133: ( 85, 85, 85,172) #555555AC graya(85,0.67451)
44: ( 86, 86, 86,170) #565656AA graya(86,0.666667)
27: ( 87, 87, 87,213) #575757D5 graya(87,0.835294)
53: ( 88, 88, 88,199) #585858C7 graya(88,0.780392)
35: ( 89, 89, 89,230) #595959E6 graya(89,0.901961)
25: ( 90, 90, 90,174) #5A5A5AAE graya(90,0.682353)
58: ( 91, 91, 91,165) #5B5B5BA5 graya(91,0.647059)
12: ( 91, 91, 91,169) #5B5B5BA9 graya(91,0.662745)
78: ( 92, 92, 92,207) #5C5C5CCF graya(92,0.811765)
99: ( 93, 93, 93,181) #5D5D5DB5 graya(93,0.709804)
4: ( 94, 94, 94,213) #5E5E5ED5 graya(94,0.835294)
8: ( 95, 95, 95,225) #5F5F5FE1 graya(95,0.882353)
39: ( 97, 97, 97,162) #616161A2 graya(97,0.635294)
41: ( 98, 98, 98,193) #626262C1 graya(98,0.756863)
11: ( 98, 98, 98,183) #626262B7 graya(98,0.717647)
193: (100,100,100,157) #6464649D graya(100,0.615686)
51: (102,102,102,168) #666666A8 graya(102,0.658824)
26: (102,102,102,227) #666666E3 graya(102,0.890196)
29: (104,104,104,209) #686868D1 graya(104,0.819608)
28: (104,104,104,152) #68686898 graya(104,0.596078)
130: (105,105,105,191) #696969BF graya(105,0.74902)
28: (105,105,105,171) #696969AB graya(105,0.670588)
76: (108,108,108,149) #6C6C6C95 graya(108,0.584314)
52: (109,109,109,187) #6D6D6DBB graya(109,0.733333)
15: (111,111,111,215) #6F6F6FD7 graya(111,0.843137)
37: (113,113,113,152) #71717198 graya(113,0.596078)
152: (116,116,116,141) #7474748D graya(116,0.552941)
38: (116,116,116,149) #74747495 graya(116,0.584314)
62: (117,117,117,175) #757575AF graya(117,0.686275)
45: (117,117,117,224) #757575E0 graya(117,0.878431)
16: (117,117,117,204) #757575CC graya(117,0.8)
52: (118,118,118,176) #767676B0 graya(118,0.690196)
11: (120,120,120,204) #787878CC graya(120,0.8)
173: (121,121,121,204) #797979CC graya(121,0.8)
47: (121,121,121,183) #797979B7 graya(121,0.717647)
89: (122,122,122,203) #7A7A7ACB graya(122,0.796078)
67: (123,123,123,202) #7B7B7BCA graya(123,0.792157)
47: (123,123,123,134) #7B7B7B86 graya(123,0.52549)
69: (124,124,124,143) #7C7C7C8F graya(124,0.560784)
4: (126,126,126,187) #7E7E7EBB graya(126,0.733333)
63: (127,127,127,198) #7F7F7FC6 graya(127,0.776471)
35: (127,127,127,130) #7F7F7F82 graya(127,0.509804)
77: (128,128,128,128) #80808080 graya(128,0.501961)
62: (128,128,128,175) #808080AF graya(128,0.686275)
107: (130,130,130,159) #8282829F graya(130,0.623529)
180: (131,131,131,125) #8383837D graya(131,0.490196)
52: (131,131,131,193) #838383C1 graya(131,0.756863)
38: (132,132,132,157) #8484849D graya(132,0.615686)
34: (133,133,133,149) #85858595 graya(133,0.584314)
2: (135,135,135,205) #878787CD graya(135,0.803922)
52: (136,136,136,121) #88888879 graya(136,0.47451)
49: (136,136,136,188) #888888BC graya(136,0.737255)
47: (137,137,137,220) #898989DC graya(137,0.862745)
47: (138,138,138,169) #8A8A8AA9 graya(138,0.662745)
25: (138,138,138,171) #8A8A8AAB graya(138,0.670588)
560: (140,140,140,117) #8C8C8C75 graya(140,0.458824)
167: (142,142,142,182) #8E8E8EB6 graya(142,0.713725)
147: (142,142,142,115) #8E8E8E73 graya(142,0.45098)
51: (142,142,142,143) #8E8E8E8F graya(142,0.560784)
239: (144,144,144,112) #90909070 graya(144,0.439216)
59: (144,144,144,155) #9090909B graya(144,0.607843)
5: (144,144,144,212) #909090D4 graya(144,0.831373)
87: (147,147,147,109) #9393936D graya(147,0.427451)
30: (147,147,147,177) #939393B1 graya(147,0.694118)
45: (149,149,149,169) #959595A9 graya(149,0.662745)
182: (150,150,150,107) #9696966B graya(150,0.419608)
35: (150,150,150,203) #969696CB graya(150,0.796078)
52: (151,151,151,104) #97979768 graya(151,0.407843)
53: (152,152,152,172) #989898AC graya(152,0.67451)
52: (152,152,152,105) #98989869 graya(152,0.411765)
109: (154,154,154,128) #9A9A9A80 graya(154,0.501961)
37: (154,154,154,161) #9A9A9AA1 graya(154,0.631373)
54: (155,155,155,101) #9B9B9B65 graya(155,0.396078)
309: (158,158,158, 99) #9E9E9E63 graya(158,0.388235)
55: (158,158,158,166) #9E9E9EA6 graya(158,0.65098)
58: (159,159,159,157) #9F9F9F9D graya(159,0.615686)
239: (160,160,160, 97) #A0A0A061 graya(160,0.380392)
85: (160,160,160, 96) #A0A0A060 graya(160,0.376471)
17: (162,162,162,171) #A2A2A2AB graya(162,0.670588)
99: (163,163,163, 94) #A3A3A35E graya(163,0.368627)
56: (163,163,163,161) #A3A3A3A1 graya(163,0.631373)
13: (163,163,163,200) #A3A3A3C8 graya(163,0.784314)
13: (164,164,164,179) #A4A4A4B3 graya(164,0.701961)
61: (165,165,165,166) #A5A5A5A6 graya(165,0.65098)
54: (165,165,165,214) #A5A5A5D6 graya(165,0.839216)
97: (166,166,166, 91) #A6A6A65B graya(166,0.356863)
93: (166,166,166,155) #A6A6A69B graya(166,0.607843)
55: (167,167,167,112) #A7A7A770 graya(167,0.439216)
1603: (169,169,169,151) #A9A9A997 graya(169,0.592157)
167: (169,169,169, 88) #A9A9A958 graya(169,0.345098)
104: (169,169,169,152) #A9A9A998 graya(169,0.596078)
75: (171,171,171, 85) #ABABAB55 graya(171,0.333333)
30: (172,172,172,197) #ACACACC5 graya(172,0.772549)
33: (173,173,173,183) #ADADADB7 graya(173,0.717647)
229: (174,174,174, 83) #AEAEAE53 graya(174,0.32549)
90: (174,174,174,200) #AEAEAEC8 graya(174,0.784314)
46: (175,175,175,172) #AFAFAFAC graya(175,0.67451)
175: (176,176,176, 80) #B0B0B050 graya(176,0.313725)
88: (179,179,179, 96) #B3B3B360 graya(179,0.376471)
80: (179,179,179, 78) #B3B3B34E graya(179,0.305882)
30: (180,180,180,199) #B4B4B4C7 graya(180,0.780392)
126: (182,182,182, 74) #B6B6B64A graya(182,0.290196)
50: (184,184,184, 72) #B8B8B848 graya(184,0.282353)
50: (185,185,185,178) #B9B9B9B2 graya(185,0.698039)
62: (187,187,187, 69) #BBBBBB45 graya(187,0.270588)
29: (187,187,187,207) #BBBBBBCF graya(187,0.811765)
87: (189,189,189,200) #BDBDBDC8 graya(189,0.784314)
404: (190,190,190, 66) #BEBEBE42 graya(190,0.258824)
284: (192,192,192, 64) #C0C0C040 graya(192,0.25098)
59: (192,192,192, 80) #C0C0C050 graya(192,0.313725)
112: (194,194,194, 62) #C2C2C23E graya(194,0.243137)
2: (194,194,194,188) #C2C2C2BC graya(194,0.737255)
76: (195,195,195,184) #C3C3C3B8 graya(195,0.721569)
93: (198,198,198, 58) #C6C6C63A graya(198,0.227451)
98: (200,200,200, 56) #C8C8C838 graya(200,0.219608)
40: (200,200,200,205) #C8C8C8CD graya(200,0.803922)
206: (201,201,201,247) #C9C9C9F7 graya(201,0.968627)
96: (201,201,201,200) #C9C9C9C8 graya(201,0.784314)
130: (203,203,203, 52) #CBCBCB34 graya(203,0.203922)
42: (204,204,204,232) #CCCCCCE8 graya(204,0.909804)
142: (205,205,205, 64) #CDCDCD40 graya(205,0.25098)
20: (205,205,205,207) #CDCDCDCF graya(205,0.811765)
57: (206,206,206,189) #CECECEBD graya(206,0.741176)
213: (207,207,207, 49) #CFCFCF31 graya(207,0.192157)
179: (208,208,208, 48) #D0D0D030 graya(208,0.188235)
60: (208,208,208,199) #D0D0D0C7 graya(208,0.780392)
95: (210,210,210, 45) #D2D2D22D graya(210,0.176471)
77: (213,213,213,200) #D5D5D5C8 graya(213,0.784314)
49: (213,213,213,204) #D5D5D5CC graya(213,0.8)
174: (215,215,215, 41) #D7D7D729 graya(215,0.160784)
119: (216,216,216,195) #D8D8D8C3 graya(216,0.764706)
98: (216,216,216, 40) #D8D8D828 graya(216,0.156863)
43: (216,216,216,180) #D8D8D8B4 graya(216,0.705882)
84: (217,217,217, 48) #D9D9D930 graya(217,0.188235)
91: (219,219,219,200) #DBDBDBC8 graya(219,0.784314)
22: (219,219,219,206) #DBDBDBCE graya(219,0.807843)
73: (220,220,220, 36) #DCDCDC24 graya(220,0.141176)
6: (221,221,221,208) #DDDDDDD0 graya(221,0.815686)
305: (223,223,223, 33) #DFDFDF21 graya(223,0.129412)
37: (223,223,223,147) #DFDFDF93 graya(223,0.576471)
159: (224,224,224, 32) #E0E0E020 graya(224,0.12549)
1468: (226,226,226,201) #E2E2E2C9 graya(226,0.788235)
84: (226,226,226, 29) #E2E2E21D graya(226,0.113725)
33: (229,229,229,118) #E5E5E576 graya(229,0.462745)
105: (230,230,230, 32) #E6E6E620 graya(230,0.12549)
210: (231,231,231, 24) #E7E7E718 graya(231,0.0941176)
23: (235,235,235, 93) #EBEBEB5D graya(235,0.364706)
318: (237,237,237, 18) #EDEDED12 graya(237,0.0705882)
31: (238,238,238, 77) #EEEEEE4D graya(238,0.301961)
107: (239,239,239, 16) #EFEFEF10 graya(239,0.0627451)
129: (240,240,240, 16) #F0F0F010 graya(240,0.0627451)
9: (241,241,241, 62) #F1F1F13E graya(241,0.243137)
125: (242,242,242, 16) #F2F2F210 graya(242,0.0627451)
315: (244,244,244, 12) #F4F4F40C graya(244,0.0470588)
31: (245,245,245, 46) #F5F5F52E graya(245,0.180392)
14: (248,248,248, 31) #F8F8F81F graya(248,0.121569)
139: (250,250,250, 11) #FAFAFA0B graya(250,0.0431373)
256244: (255,255,255, 0) #FFFFFF00 graya(255,0)
Code: Select all
$ magick logo: \( +clone -negate -colorspace HSV -separate -delete 0,1 \) -compose copy_opacity -composite -type GrayScaleAlpha x.png
$ magick identify -verbose x.png | grep -i color
Colorspace: sRGB
Colors: 253
Matte color: grey74
Background color: srgb(4,7,7)
Border color: srgb(223,223,223)
Transparent color: none
png:bKGD: chunk was found (see Background color, above)
png:IHDR.color-type-orig: 3
png:IHDR.color_type: 3 (Indexed)
png:PLTE.number_colors: 254
Code: Select all
$ magick logo: \( +clone -negate -colorspace HSV -separate -delete 0,1 \) -compose copy_opacity -composite -type GrayScaleAlpha -define png:color-type=4 x.png
magick.exe: Cannot write image with defined png:bit-depth or png:color-type. `x.png' @ warning/png.c/MagickPNGWarningHandler/1748.
color-type=2 works but it lost transparency.
Note that I can create the file by passing tiff.
Code: Select all
$ magick logo: \( +clone -negate -colorspace HSV -separate -delete 0,1 \) -compose copy_opacity -composite -type GrayScaleAlpha TIFF:- | magick - x.png
$ magick identify -verbose x.png | grep -i color
Colorspace: Gray
Colors: 253
Matte color: grey74
Background color: white
Border color: srgb(223,223,223)
Transparent color: none
png:bKGD: chunk was found (see Background color, above)
png:IHDR.color-type-orig: 4
png:IHDR.color_type: 4 (GrayAlpha)