In IM 6, you will always have 3 channels even for grayscale. So your deletes are unnecessary. IM 7 will allow 1 channel images.
convert xc:"gray(6)" xc:"rgb(81,180,7)" -set colorspace sRGB -append -depth 8 mysrgb.png
-grayscale rec709luminance is the proper linear grayscale when using sRGB (whereas rec709luma is non-linear gray). See the last bullet in the section at
where it indicates that sRGB uses rec709 and not rec601.
But IM (actually the image formats such as png or jpg or gif or tiff, etc) have no way to keep track of the fact that it is linear gray rather than non-linear gray. You can see this from the verbose information.
Code: Select all
Image: mysrgb_lin.png
Format: PNG (Portable Network Graphics)
Mime type: image/png
Class: PseudoClass
Geometry: 1x2+0+0
Units: Undefined
Type: Grayscale <==== does not say whether linear or nonlinear
Endianess: Undefined
Colorspace: Gray <==== does not say whether linear or nonlinear
Depth: 8/1-bit
Channel depth:
gray: 8-bit
Channel statistics:
Gray:
min: 0 (0)
max: 88 (0.345098)
mean: 44 (0.172549)
standard deviation: 44 (0.172549)
kurtosis: -2
skewness: 0
Colors: 2
Histogram:
1: ( 0, 0, 0) #000000 gray(0)
1: ( 88, 88, 88) #585858 gray(88)
Colormap entries: 256
Colormap:
0: ( 0, 0, 0) #000000 gray(0)
1: ( 1, 1, 1) #010101 gray(1)
2: ( 2, 2, 2) #020202 gray(2)
3: ( 3, 3, 3) #030303 gray(3)
4: ( 4, 4, 4) #040404 gray(4)
5: ( 5, 5, 5) #050505 gray(5)
6: ( 6, 6, 6) #060606 gray(6)
7: ( 7, 7, 7) #070707 gray(7)
8: ( 8, 8, 8) #080808 gray(8)
9: ( 9, 9, 9) #090909 gray(9)
10: ( 10, 10, 10) #0A0A0A gray(10)
11: ( 11, 11, 11) #0B0B0B gray(11)
12: ( 12, 12, 12) #0C0C0C gray(12)
13: ( 13, 13, 13) #0D0D0D gray(13)
14: ( 14, 14, 14) #0E0E0E gray(14)
15: ( 15, 15, 15) #0F0F0F gray(15)
16: ( 16, 16, 16) #101010 gray(16)
17: ( 17, 17, 17) #111111 gray(17)
18: ( 18, 18, 18) #121212 gray(18)
19: ( 19, 19, 19) #131313 gray(19)
20: ( 20, 20, 20) #141414 gray(20)
21: ( 21, 21, 21) #151515 gray(21)
22: ( 22, 22, 22) #161616 gray(22)
23: ( 23, 23, 23) #171717 gray(23)
24: ( 24, 24, 24) #181818 gray(24)
25: ( 25, 25, 25) #191919 gray(25)
26: ( 26, 26, 26) #1A1A1A gray(26)
27: ( 27, 27, 27) #1B1B1B gray(27)
28: ( 28, 28, 28) #1C1C1C gray(28)
29: ( 29, 29, 29) #1D1D1D gray(29)
30: ( 30, 30, 30) #1E1E1E gray(30)
31: ( 31, 31, 31) #1F1F1F gray(31)
32: ( 32, 32, 32) #202020 gray(32)
33: ( 33, 33, 33) #212121 gray(33)
34: ( 34, 34, 34) #222222 gray(34)
35: ( 35, 35, 35) #232323 gray(35)
36: ( 36, 36, 36) #242424 gray(36)
37: ( 37, 37, 37) #252525 gray(37)
38: ( 38, 38, 38) #262626 gray(38)
39: ( 39, 39, 39) #272727 gray(39)
40: ( 40, 40, 40) #282828 gray(40)
41: ( 41, 41, 41) #292929 gray(41)
42: ( 42, 42, 42) #2A2A2A gray(42)
43: ( 43, 43, 43) #2B2B2B gray(43)
44: ( 44, 44, 44) #2C2C2C gray(44)
45: ( 45, 45, 45) #2D2D2D gray(45)
46: ( 46, 46, 46) #2E2E2E gray(46)
47: ( 47, 47, 47) #2F2F2F gray(47)
48: ( 48, 48, 48) #303030 gray(48)
49: ( 49, 49, 49) #313131 gray(49)
50: ( 50, 50, 50) #323232 gray(50)
51: ( 51, 51, 51) #333333 gray(51)
52: ( 52, 52, 52) #343434 gray(52)
53: ( 53, 53, 53) #353535 gray(53)
54: ( 54, 54, 54) #363636 gray(54)
55: ( 55, 55, 55) #373737 gray(55)
56: ( 56, 56, 56) #383838 gray(56)
57: ( 57, 57, 57) #393939 gray(57)
58: ( 58, 58, 58) #3A3A3A gray(58)
59: ( 59, 59, 59) #3B3B3B gray(59)
60: ( 60, 60, 60) #3C3C3C gray(60)
61: ( 61, 61, 61) #3D3D3D gray(61)
62: ( 62, 62, 62) #3E3E3E gray(62)
63: ( 63, 63, 63) #3F3F3F gray(63)
64: ( 64, 64, 64) #404040 gray(64)
65: ( 65, 65, 65) #414141 gray(65)
66: ( 66, 66, 66) #424242 gray(66)
67: ( 67, 67, 67) #434343 gray(67)
68: ( 68, 68, 68) #444444 gray(68)
69: ( 69, 69, 69) #454545 gray(69)
70: ( 70, 70, 70) #464646 gray(70)
71: ( 71, 71, 71) #474747 gray(71)
72: ( 72, 72, 72) #484848 gray(72)
73: ( 73, 73, 73) #494949 gray(73)
74: ( 74, 74, 74) #4A4A4A gray(74)
75: ( 75, 75, 75) #4B4B4B gray(75)
76: ( 76, 76, 76) #4C4C4C gray(76)
77: ( 77, 77, 77) #4D4D4D gray(77)
78: ( 78, 78, 78) #4E4E4E gray(78)
79: ( 79, 79, 79) #4F4F4F gray(79)
80: ( 80, 80, 80) #505050 gray(80)
81: ( 81, 81, 81) #515151 gray(81)
82: ( 82, 82, 82) #525252 gray(82)
83: ( 83, 83, 83) #535353 gray(83)
84: ( 84, 84, 84) #545454 gray(84)
85: ( 85, 85, 85) #555555 gray(85)
86: ( 86, 86, 86) #565656 gray(86)
87: ( 87, 87, 87) #575757 gray(87)
88: ( 88, 88, 88) #585858 gray(88)
89: ( 89, 89, 89) #595959 gray(89)
90: ( 90, 90, 90) #5A5A5A gray(90)
91: ( 91, 91, 91) #5B5B5B gray(91)
92: ( 92, 92, 92) #5C5C5C gray(92)
93: ( 93, 93, 93) #5D5D5D gray(93)
94: ( 94, 94, 94) #5E5E5E gray(94)
95: ( 95, 95, 95) #5F5F5F gray(95)
96: ( 96, 96, 96) #606060 gray(96)
97: ( 97, 97, 97) #616161 gray(97)
98: ( 98, 98, 98) #626262 gray(98)
99: ( 99, 99, 99) #636363 gray(99)
100: (100,100,100) #646464 gray(100)
101: (101,101,101) #656565 gray(101)
102: (102,102,102) #666666 gray(102)
103: (103,103,103) #676767 gray(103)
104: (104,104,104) #686868 gray(104)
105: (105,105,105) #696969 gray(105)
106: (106,106,106) #6A6A6A gray(106)
107: (107,107,107) #6B6B6B gray(107)
108: (108,108,108) #6C6C6C gray(108)
109: (109,109,109) #6D6D6D gray(109)
110: (110,110,110) #6E6E6E gray(110)
111: (111,111,111) #6F6F6F gray(111)
112: (112,112,112) #707070 gray(112)
113: (113,113,113) #717171 gray(113)
114: (114,114,114) #727272 gray(114)
115: (115,115,115) #737373 gray(115)
116: (116,116,116) #747474 gray(116)
117: (117,117,117) #757575 gray(117)
118: (118,118,118) #767676 gray(118)
119: (119,119,119) #777777 gray(119)
120: (120,120,120) #787878 gray(120)
121: (121,121,121) #797979 gray(121)
122: (122,122,122) #7A7A7A gray(122)
123: (123,123,123) #7B7B7B gray(123)
124: (124,124,124) #7C7C7C gray(124)
125: (125,125,125) #7D7D7D gray(125)
126: (126,126,126) #7E7E7E gray(126)
127: (127,127,127) #7F7F7F gray(127)
128: (128,128,128) #808080 gray(128)
129: (129,129,129) #818181 gray(129)
130: (130,130,130) #828282 gray(130)
131: (131,131,131) #838383 gray(131)
132: (132,132,132) #848484 gray(132)
133: (133,133,133) #858585 gray(133)
134: (134,134,134) #868686 gray(134)
135: (135,135,135) #878787 gray(135)
136: (136,136,136) #888888 gray(136)
137: (137,137,137) #898989 gray(137)
138: (138,138,138) #8A8A8A gray(138)
139: (139,139,139) #8B8B8B gray(139)
140: (140,140,140) #8C8C8C gray(140)
141: (141,141,141) #8D8D8D gray(141)
142: (142,142,142) #8E8E8E gray(142)
143: (143,143,143) #8F8F8F gray(143)
144: (144,144,144) #909090 gray(144)
145: (145,145,145) #919191 gray(145)
146: (146,146,146) #929292 gray(146)
147: (147,147,147) #939393 gray(147)
148: (148,148,148) #949494 gray(148)
149: (149,149,149) #959595 gray(149)
150: (150,150,150) #969696 gray(150)
151: (151,151,151) #979797 gray(151)
152: (152,152,152) #989898 gray(152)
153: (153,153,153) #999999 gray(153)
154: (154,154,154) #9A9A9A gray(154)
155: (155,155,155) #9B9B9B gray(155)
156: (156,156,156) #9C9C9C gray(156)
157: (157,157,157) #9D9D9D gray(157)
158: (158,158,158) #9E9E9E gray(158)
159: (159,159,159) #9F9F9F gray(159)
160: (160,160,160) #A0A0A0 gray(160)
161: (161,161,161) #A1A1A1 gray(161)
162: (162,162,162) #A2A2A2 gray(162)
163: (163,163,163) #A3A3A3 gray(163)
164: (164,164,164) #A4A4A4 gray(164)
165: (165,165,165) #A5A5A5 gray(165)
166: (166,166,166) #A6A6A6 gray(166)
167: (167,167,167) #A7A7A7 gray(167)
168: (168,168,168) #A8A8A8 gray(168)
169: (169,169,169) #A9A9A9 gray(169)
170: (170,170,170) #AAAAAA gray(170)
171: (171,171,171) #ABABAB gray(171)
172: (172,172,172) #ACACAC gray(172)
173: (173,173,173) #ADADAD gray(173)
174: (174,174,174) #AEAEAE gray(174)
175: (175,175,175) #AFAFAF gray(175)
176: (176,176,176) #B0B0B0 gray(176)
177: (177,177,177) #B1B1B1 gray(177)
178: (178,178,178) #B2B2B2 gray(178)
179: (179,179,179) #B3B3B3 gray(179)
180: (180,180,180) #B4B4B4 gray(180)
181: (181,181,181) #B5B5B5 gray(181)
182: (182,182,182) #B6B6B6 gray(182)
183: (183,183,183) #B7B7B7 gray(183)
184: (184,184,184) #B8B8B8 gray(184)
185: (185,185,185) #B9B9B9 gray(185)
186: (186,186,186) #BABABA gray(186)
187: (187,187,187) #BBBBBB gray(187)
188: (188,188,188) #BCBCBC gray(188)
189: (189,189,189) #BDBDBD gray(189)
190: (190,190,190) #BEBEBE gray(190)
191: (191,191,191) #BFBFBF gray(191)
192: (192,192,192) #C0C0C0 gray(192)
193: (193,193,193) #C1C1C1 gray(193)
194: (194,194,194) #C2C2C2 gray(194)
195: (195,195,195) #C3C3C3 gray(195)
196: (196,196,196) #C4C4C4 gray(196)
197: (197,197,197) #C5C5C5 gray(197)
198: (198,198,198) #C6C6C6 gray(198)
199: (199,199,199) #C7C7C7 gray(199)
200: (200,200,200) #C8C8C8 gray(200)
201: (201,201,201) #C9C9C9 gray(201)
202: (202,202,202) #CACACA gray(202)
203: (203,203,203) #CBCBCB gray(203)
204: (204,204,204) #CCCCCC gray(204)
205: (205,205,205) #CDCDCD gray(205)
206: (206,206,206) #CECECE gray(206)
207: (207,207,207) #CFCFCF gray(207)
208: (208,208,208) #D0D0D0 gray(208)
209: (209,209,209) #D1D1D1 gray(209)
210: (210,210,210) #D2D2D2 gray(210)
211: (211,211,211) #D3D3D3 gray(211)
212: (212,212,212) #D4D4D4 gray(212)
213: (213,213,213) #D5D5D5 gray(213)
214: (214,214,214) #D6D6D6 gray(214)
215: (215,215,215) #D7D7D7 gray(215)
216: (216,216,216) #D8D8D8 gray(216)
217: (217,217,217) #D9D9D9 gray(217)
218: (218,218,218) #DADADA gray(218)
219: (219,219,219) #DBDBDB gray(219)
220: (220,220,220) #DCDCDC gray(220)
221: (221,221,221) #DDDDDD gray(221)
222: (222,222,222) #DEDEDE gray(222)
223: (223,223,223) #DFDFDF gray(223)
224: (224,224,224) #E0E0E0 gray(224)
225: (225,225,225) #E1E1E1 gray(225)
226: (226,226,226) #E2E2E2 gray(226)
227: (227,227,227) #E3E3E3 gray(227)
228: (228,228,228) #E4E4E4 gray(228)
229: (229,229,229) #E5E5E5 gray(229)
230: (230,230,230) #E6E6E6 gray(230)
231: (231,231,231) #E7E7E7 gray(231)
232: (232,232,232) #E8E8E8 gray(232)
233: (233,233,233) #E9E9E9 gray(233)
234: (234,234,234) #EAEAEA gray(234)
235: (235,235,235) #EBEBEB gray(235)
236: (236,236,236) #ECECEC gray(236)
237: (237,237,237) #EDEDED gray(237)
238: (238,238,238) #EEEEEE gray(238)
239: (239,239,239) #EFEFEF gray(239)
240: (240,240,240) #F0F0F0 gray(240)
241: (241,241,241) #F1F1F1 gray(241)
242: (242,242,242) #F2F2F2 gray(242)
243: (243,243,243) #F3F3F3 gray(243)
244: (244,244,244) #F4F4F4 gray(244)
245: (245,245,245) #F5F5F5 gray(245)
246: (246,246,246) #F6F6F6 gray(246)
247: (247,247,247) #F7F7F7 gray(247)
248: (248,248,248) #F8F8F8 gray(248)
249: (249,249,249) #F9F9F9 gray(249)
250: (250,250,250) #FAFAFA gray(250)
251: (251,251,251) #FBFBFB gray(251)
252: (252,252,252) #FCFCFC gray(252)
253: (253,253,253) #FDFDFD gray(253)
254: (254,254,254) #FEFEFE gray(254)
255: (255,255,255) #FFFFFF gray(255)
Rendering intent: Perceptual
Gamma: 0.454545
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
Background color: gray(255)
Border color: gray(223)
Matte color: gray(189)
Transparent color: gray(0)
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 1x2+0+0
Dispose: Undefined
Iterations: 0
Compression: Zip
Orientation: Undefined
Properties:
date:create: 2013-10-02T15:10:39-07:00
date:modify: 2013-10-02T15:10:39-07:00
png:bKGD: chunk was found (see Background color, above)
png:gAMA: gamma=1 (See Gamma, above)
png:IHDR.bit-depth-orig: 8
png:IHDR.bit_depth: 8
png:IHDR.color-type-orig: 0
png:IHDR.color_type: 0 (Grayscale) <==== does not say whether linear or nonlinear
png:IHDR.interlace_method: 0 (Not interlaced)
png:IHDR.width,height: 1, 2
png:text: 2 tEXt/zTXt/iTXt chunks were found
signature: 62c2a0d38aeb55f6b569cb9fb3a78c17b0386618764f134cbd395826f3256e78
Artifacts:
filename: mysrgb_lin.png
verbose: true
Tainted: True
Filesize: 197B
Number pixels: 2
Pixels per second: 2PB
User time: 0.000u
Elapsed time: 0:01.000
Version: ImageMagick 6.8.7-0 2013-09-26 Q16 http://www.imagemagick.org
As you can see there is no flag that says it is linear only simply grayscale. Thus you must specify linear or non-linear by using -set colorspace. Thus to convert it back to sRGB, you will then set the colorspace as RGB (linear) and then change the colorspace to nonlinear sRGB.
convert mysrgb.png -grayscale rec709luminance -set colorspace RGB -colorspace sRGB txt:
As far as I understand it, the above is correct (within the limits of 8-bit data)