Page 1 of 1

Converting from and to xpm corrupts the image

Posted: 2013-04-29T02:25:02-07:00
by gber
Converting from and to xpm corrupts the image, that is it alters the colors introducing "noise", e.g. using convert from and to xpm which should be a no-op results in this:

Code: Select all

$ cat decoration-template.xpm
/* XPM */
static char * decoration_template_xpm[] = {
"28 36 29 1",
"       c None",
".      c #555753",
"+      c #A19D9A",
"@      c #BABDB6",
"#      c #FFFFFF",
"$      c #888A85",
"%      c #E9E8E7",
"&      c #898B86",
"*      c #8A8C87",
"=      c #8B8D88",
"-      c #8C8E89",
";      c #8D8F8A",
">      c #8E918B",
",      c #90928C",
"'      c #91938D",
")      c #92948F",
"!      c #939590",
"~      c #949691",
"{      c #959792",
"]      c #969893",
"^      c #979994",
"/      c #989A95",
"(      c #999C96",
"_      c #9A9D97",
":      c #9B9E98",
"<      c #9D9F99",
"[      c #9EA09A",
"}      c #9FA19B",
"|      c #A0A29C",
"     .........     +++++++++",
"   ..@@@@@@@@@   ++#########",
"  .@@$$$$$$$$$  +##%%%%%%%%%",
" .@&&&&&&&&&&& +#%%%%%%%%%%%",
" .@*********** +#%%%%%%%%%%%",
".@============+#%%%%%%%%%%%%",
".@------------+#%%%%%%%%%%%%",
".@;;;;;;;;;;;;+#%%%%%%%%%%%%",
".@>>>>>>>>>>>>+#%%%%%%%%%%%%",
".@,,,,,,,,,,,,+#%%%%%%%%%%%%",
".@''''''''''''+#%%%%%%%%%%%%",
".@))))))))))))+#%%%%%%%%%%%%",
".@!!!!!!!!!!!!+#%%%%%%%%%%%%",
".@~~~~~~~~~~~~+#%%%%%%%%%%%%",
".@{{{{{{{{{{{{+#%%%%%%%%%%%%",
".@]]]]]]]]]]]]+#%%%%%%%%%%%%",
".@^^^^^^^^^^^^+#%%%%%%%%%%%%",
".@////////////+#%%%%%%%%%%%%",
".@((((((((((((+#%%%%%%%%%%%%",
".@____________+#%%%%%%%%%%%%",
".@::::::::::::+#%%%%%%%%%%%%",
".@<<<<<<<<<<<<+#%%%%%%%%%%%%",
".@[[[[[[[[[[[[+#%%%%%%%%%%%%",
".@}}}}}}}}}}}}+#%%%%%%%%%%%%",
".@||||||||||||+#%%%%%%%%%%%%",
".@%           +#%           ",
".@%           +#%           ",
".@%           +#%           ",
".@%           +#%           ",
".@%           +#%           ",
".@%           +#%           ",
".@%           +#%           ",
".@%           +#%           ",
".@%%%%%%%%%%%%+#%%%%%%%%%%%%",
".@@@@@@@@@@@@@+#############",
"..............++++++++++++++"};

$ convert decoration-template.xpm xpm:-
/* XPM */
static char *xpm__[] = {
/* columns rows colors chars-per-pixel */
"28 36 29 1 ",
"  c #555557575353",
". c #88888A8A8585",
"X c #89898B8B8686",
"o c #8A8A8C8C8787",
"O c #8B8B8D8D8888",
"+ c #8C8C8E8E8989",
"@ c #8D8D8F8F8A8A",
"# c #8E8E91918B8B",
"$ c #909092928C8C",
"% c #919193938D8D",
"& c #929294948F8F",
"* c #939395959090",
"= c #949496969191",
"- c #959597979292",
"; c #969698989393",
": c #979799999494",
"> c #98989A9A9595",
", c #99999C9C9696",
"< c #9A9A9D9D9797",
"1 c #9B9B9E9E9898",
"2 c #9D9D9F9F9999",
"3 c #A1A19D9D9A9A",
"4 c #9E9EA0A09A9A",
"5 c #9F9FA1A19B9B",
"6 c #A0A0A2A29C9C",
"7 c #BABABDBDB6B6",
"8 c #E9E9E8E8E7E7",
"9 c gray100",
"0 c None",
/* pixels */
"00000         00000333333333",
"000  77777777700033999999999",
"00 77.X...XX..00399888888888",
"0 7XXXXXXXXXXX03988888888888",
"0 7oXoooXooXoo03988888888888",
" 7++OOOO+++OOO39888888888888",
" 7++++++++++++39888888888888",
" 7+#++#++#++#+39888888888888",
" 7##$$########39888888888888",
" 7$$$$$$$$$$$#39888888888888",
" 7$$$$$$$$$$$&39888888888888",
" 7**&**&*&**&&39888888888888",
" 7************39888888888888",
" 7*-*-*--*-*-*39888888888888",
" 7------------39888888888888",
" 7;;;;;;;;;;;;39888888888888",
" 7>;>;>;>;>;>;39888888888888",
" 7>>>>>>>>>>>>39888888888888",
" 7,,,,,,,,,,,,39888888888888",
" 71,1,1,1,1,1,39888888888888",
" 711111111111139888888888888",
" 722222222222239888888888888",
" 752522525525239888888888888",
" 755555555555539888888888888",
" 766666666666639888888888888",
" 780000000000039800000000000",
" 780000000000039800000000000",
" 780000000000039800000000000",
" 780000000000039800000000000",
" 780000000000039800000000000",
" 780000000000039800000000000",
" 780000000000039800000000000",
" 780000000000039800000000000",
" 788888888888839888888888888",
" 777777777777739999999999999",
"              33333333333333"
};
I'm using ImageMagick 6.7.8-8 2013-03-18 Q16, I'm fairly sure this didn't happen with older versions of IM, I still have XPM images from about three years ago which were converted with IM without this "noise" being added.

Re: Converting from and to xpm corrupts the image

Posted: 2013-04-30T17:51:08-07:00
by magick
Add '-dither none' to your command line.

Re: Converting from and to xpm corrupts the image

Posted: 2013-05-01T01:31:12-07:00
by gber
Thanks, that fixed the conversion. Now I'm facing a different kind of "corruption", when cutting out part of the posted image via -crop, some of the transparent pixels (ie. color "None") are turned into black:

Code: Select all

$ convert  -dither none -crop 6x25+0+0 decoration-template.xpm xpm:-
/* XPM */
static char *xpm__[] = {
/* columns rows colors chars-per-pixel */
"6 25 150 2 ",
"   c None",
".  c black",
"X  c black",
"o  c black",
"O  c black",
"+  c #555557575353",
"@  c black",
"#  c black",
"$  c black",
"%  c #555557575353",
"&  c #555557575353",
"*  c #BABABDBDB6B6",
"=  c black",
"-  c black",
";  c #555557575353",
":  c #BABABDBDB6B6",
">  c #BABABDBDB6B6",
",  c #88888A8A8585",
"<  c black",
"1  c #555557575353",
"2  c #BABABDBDB6B6",
"3  c #89898B8B8686",
"4  c #89898B8B8686",
"5  c #89898B8B8686",
"6  c black",
"7  c #555557575353",
"8  c #BABABDBDB6B6",
"9  c #8A8A8C8C8787",
"0  c #8A8A8C8C8787",
"q  c #8A8A8C8C8787",
"w  c #555557575353",
"e  c #BABABDBDB6B6",
"r  c #8B8B8D8D8888",
"t  c #8B8B8D8D8888",
"y  c #8B8B8D8D8888",
"u  c #8B8B8D8D8888",
"i  c #555557575353",
"p  c #BABABDBDB6B6",
"a  c #8C8C8E8E8989",
"s  c #8C8C8E8E8989",
"d  c #8C8C8E8E8989",
"f  c #8C8C8E8E8989",
"g  c #555557575353",
"h  c #BABABDBDB6B6",
"j  c #8D8D8F8F8A8A",
"k  c #8D8D8F8F8A8A",
"l  c #8D8D8F8F8A8A",
"z  c #8D8D8F8F8A8A",
"x  c #555557575353",
"c  c #BABABDBDB6B6",
"v  c #8E8E91918B8B",
"b  c #8E8E91918B8B",
"n  c #8E8E91918B8B",
"m  c #8E8E91918B8B",
"M  c #555557575353",
"N  c #BABABDBDB6B6",
"B  c #909092928C8C",
"V  c #909092928C8C",
"C  c #909092928C8C",
"Z  c #909092928C8C",
"A  c #555557575353",
"S  c #BABABDBDB6B6",
"D  c #919193938D8D",
"F  c #919193938D8D",
"G  c #919193938D8D",
"H  c #919193938D8D",
"J  c #555557575353",
"K  c #BABABDBDB6B6",
"L  c #929294948F8F",
"P  c #929294948F8F",
"I  c #929294948F8F",
"U  c #929294948F8F",
"Y  c #555557575353",
"T  c #BABABDBDB6B6",
"R  c #939395959090",
"E  c #939395959090",
"W  c #939395959090",
"Q  c #939395959090",
"!  c #555557575353",
"~  c #BABABDBDB6B6",
"^  c #949496969191",
"/  c #949496969191",
"(  c #949496969191",
")  c #949496969191",
"_  c #555557575353",
"`  c #BABABDBDB6B6",
"'  c #959597979292",
"]  c #959597979292",
"[  c #959597979292",
"{  c #959597979292",
"}  c #555557575353",
"|  c #BABABDBDB6B6",
" . c #969698989393",
".. c #969698989393",
"X. c #969698989393",
"o. c #969698989393",
"O. c #555557575353",
"+. c #BABABDBDB6B6",
"@. c #979799999494",
"#. c #979799999494",
"$. c #979799999494",
"%. c #979799999494",
"&. c #555557575353",
"*. c #BABABDBDB6B6",
"=. c #98989A9A9595",
"-. c #98989A9A9595",
";. c #98989A9A9595",
":. c #98989A9A9595",
">. c #555557575353",
",. c #BABABDBDB6B6",
"<. c #99999C9C9696",
"1. c #99999C9C9696",
"2. c #99999C9C9696",
"3. c #99999C9C9696",
"4. c #555557575353",
"5. c #BABABDBDB6B6",
"6. c #9A9A9D9D9797",
"7. c #9A9A9D9D9797",
"8. c #9A9A9D9D9797",
"9. c #9A9A9D9D9797",
"0. c #555557575353",
"q. c #BABABDBDB6B6",
"w. c #9B9B9E9E9898",
"e. c #9B9B9E9E9898",
"r. c #9B9B9E9E9898",
"t. c #9B9B9E9E9898",
"y. c #555557575353",
"u. c #BABABDBDB6B6",
"i. c #9D9D9F9F9999",
"p. c #9D9D9F9F9999",
"a. c #9D9D9F9F9999",
"s. c #9D9D9F9F9999",
"d. c #555557575353",
"f. c #BABABDBDB6B6",
"g. c #9E9EA0A09A9A",
"h. c #9E9EA0A09A9A",
"j. c #9E9EA0A09A9A",
"k. c #9E9EA0A09A9A",
"l. c #555557575353",
"z. c #BABABDBDB6B6",
"x. c #9F9FA1A19B9B",
"c. c #9F9FA1A19B9B",
"v. c #9F9FA1A19B9B",
"b. c #9F9FA1A19B9B",
"n. c #555557575353",
"m. c #BABABDBDB6B6",
"M. c #A0A0A2A29C9C",
"N. c #A0A0A2A29C9C",
"B. c #A0A0A2A29C9C",
"V. c #A0A0A2A29C9C",
/* pixels */
"  . X o O + ",
"@ # $ % & * ",
"= - ; : > , ",
"< 1 2 3 4 5 ",
"6 7 8 9 0 q ",
"w e r t y u ",
"i p a s d f ",
"g h j k l z ",
"x c v b n m ",
"M N B V C Z ",
"A S D F G H ",
"J K L P I U ",
"Y T R E W Q ",
"! ~ ^ / ( ) ",
"_ ` ' ] [ { ",
"} |  ...X.o.",
"O.+.@.#.$.%.",
"&.*.=.-.;.:.",
">.,.<.1.2.3.",
"4.5.6.7.8.9.",
"0.q.w.e.r.t.",
"y.u.i.p.a.s.",
"d.f.g.h.j.k.",
"l.z.x.c.v.b.",
"n.m.M.N.B.V."
};
Why is this and how can I avoid it?
It looks also weird that colors are all duplicated.