color.c: X11Compliance vs. XPMCompliance

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
Petr
Posts: 51
Joined: 2010-01-07T09:37:51-07:00
Authentication code: 8675309

color.c: X11Compliance vs. XPMCompliance

Post by Petr »

Is following correct? Following colors are marked as X11Compliance, but not as XPMCompliance:
-foo{1,2,3,4}
-greyN
-*Grey
-DarkBlue
-DarkCyan
-DarkGray
-DarkMagenta
-DarkRed
-LightGreen
-white

Actually, I don't know the difference between X11 and XPM colors (didn't see the list of xpm colors, where is it?). I believe *{G,g}rey* was removed to avoid duplicity, I understood foo{1,2,3,4} was removed but the rest seems fishy to me. This is with 6.8.5-7. Sorry if I am missing something.

Thanks!
Petr
Posts: 51
Joined: 2010-01-07T09:37:51-07:00
Authentication code: 8675309

Re: color.c: X11Compliance vs. XPMCompliance

Post by Petr »

The consequence is, that e. g. dddback.xpm from ddd package fails to convert to other format. Even if QueryColorCompliance() throws only warning, later check in xpm.c throws error on

Code: Select all

  if (j < (ssize_t) image->colors)
    ThrowReaderException(CorruptImageError,"CorruptImage");
dddback.xpm defines colors as follows:

Code: Select all

". c White",
"X c Grey90",
Petr
Posts: 51
Joined: 2010-01-07T09:37:51-07:00
Authentication code: 8675309

Re: color.c: X11Compliance vs. XPMCompliance

Post by Petr »

Dunno if it is saying anything, but

Code: Select all

#include<stdlib.h>
#include<X11/Xlib.h>
#include<X11/xpm.h>
#include <stdio.h>

int main(int argc, char *argv[])
{
  Display *dpy;
  XImage *img;


  /* open the display (connect to the X server) */
  dpy = XOpenDisplay(getenv("DISPLAY"));


  /* read the image */
  if (XpmReadFileToImage(dpy, argv[1], &img, NULL, NULL)) {
      printf("Error reading file\n");
      exit(1);
  }

  printf("Ok\n");

  XCloseDisplay(dpy);
  return 0;
}
opens this image without any error.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: color.c: X11Compliance vs. XPMCompliance

Post by anthony »

XPM images need to use X11 colors. But IM generally uses SVG colors.

The difference is in only a few specific colors.
See IM Examples, Color Name Conflicts
http://www.imagemagick.org/Usage/color_ ... _conflicts

My last round of testing ensured that XPM colors are read and are written using X11 colors,
though you would need to be careful in color specifications on the command line (which uses SVG color names) when using this image format.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Petr
Posts: 51
Joined: 2010-01-07T09:37:51-07:00
Authentication code: 8675309

Re: color.c: X11Compliance vs. XPMCompliance

Post by Petr »

Following patch:

Code: Select all

Index: ImageMagick-6.8.5-7/coders/xpm.c
===================================================================
--- ImageMagick-6.8.5-7.orig/coders/xpm.c
+++ ImageMagick-6.8.5-7/coders/xpm.c
@@ -382,7 +382,7 @@ static Image *ReadXPMImage(const ImageIn
         image->storage_class=DirectClass;
         image->matte=MagickTrue;
       }
-    status=QueryColorCompliance(target,XPMCompliance,&image->colormap[j],
+    status=QueryColorCompliance(target,X11Compliance,&image->colormap[j],
       exception);
     if (status == MagickFalse)
       break;
I need to read for example dddback.xpm from ddd-3.3.12 xpm. And the offended change is here:
http://trac.imagemagick.org/changeset/1 ... ders/xpm.c
The reason is, that White and Grey90 is not XPMCompliance defined in ImageMagick, as far as I can see.

Code: Select all

/* XPM */
static char * dddback_xpm[] = {
/* $Id: dddback.xpm 6405 2003-05-24 15:27:46Z apg $
 * DDD Backdrop.  Copyright (C) 1998 TU Braunschweig, Germany.
 * For details on DDD, see `http://www.gnu.org/software/ddd/'.
 * columns rows colors chars-per-pixel */
"150 150 2 1",
". c White",
"X c Grey90",
/* pixels */
"...........X.......................................................................................................................XX...X..XX.........",
"...........XX......................................................................................................................XX....X.XX.........",
"XXXXXXXXX.X.XX.....................................................................................................................X.....XXXXX.XXX..XX",
"XXXXXXXXX.X.XX.....................................................................................................................X.....X..XX.XXXX...",
".XXXXXXX..X..X.....................................................................................................................X.....XX.XX..XXXXX.",
".........XXX.X.....................................................................................................................X......XXXXX.......",
"........XXXXX......................................................................................................................XX......X.XXX......",
"XXXXX..XXXXXX......................................................................................................................XX......XX.XXX...XX",
"XX....XXXXXXXX.....................................................................................................................XX.......XXXXXXX...",
"...XXXXXXXXXXX......................................................................................................................X........X..XXXXX.",
"XXXXXXXXXXXXXXX....................................................................................................................X..........XXXXXXXX",
"XXXX..XXXXXXXXXX...................................................................................................................X............X..XXX",
"........XXXXXXXXX.................................................................................................................X..............X...X",
"..........XXXXXXXX..............................................................................................................XX................XXX.",
"............XXXXXXX.............................................................................................................X.....................",
".............XXXXXXX..................................................................................................................................",
"..............XXXXXXX.................................................................................................................................",
"...............XXXXXXX................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................X............X..................................................................",
"......................................................................X...........XX..................................................................",
".......................................................................X..........X...................................................................",
".......................................................................XX........X....................................................................",
".........................................................XX.............XX......XX....................................................................",
"...........................................................XX............X.....X...............X......................................................",
".............................................................X............X.X.X..............XX.......................................................",
"..............................................................X............X.X..............X.........................................................",
"...............................................................X..........XX.XX...........XX..........................................................",
"...............................................................XX.....XX..X...X..XX.....XXX...........................................................",
"................................................................X.....X.XXX...XXX.X.....X.............................................................",
"................................................................XX...XX...X...X...X...XX..............................................................",
"..................................................................XXXXX....XXX....X...X...............................................................",
"...................................................................XX.XX.........XX.XX................................................................",
"......................................................................XXX.......XXXXX.................................................................",
"........................................................................XXXXXXXXX.....................................................................",
"........................................................................X.......X.....................................................................",
"......................................................................XXXXX...XXXXX...................................................................",
".....................................................................X.....XXXXXXX.X..XXX.............................................................",
"..............................................................XX....XX...XXXX.....XXXXXXXX............................................................",
".............................................................XXXXXXXXX..XX...........X...XX...........................................................",
"............................................................XX....XX.XXXX..XXXXXXXXX..X...XX..........................................................",
"............................................................X....XX...XX..XXXXXXXXXXX..X..XX..........................................................",
"...........................................................XX....X....X.................X..X..........................................................",
"...........................................................XX...XXXXXXX..................X..XX........................................................",
"..........................................................XX....X...XX...................X...XX.......................................................",
".........................................................XX....XX...XX.XXXXXXXXXXXXXXXXX.X.....XX.....................................................",
".........................................................X...XX.X..XX..X.XXXXXXXXXXXXXXX.XX......XX...................................................",
"........................................................X...XXX.XXXXX..X..XXXXXXXXXXXXXX..X...........................................................",
"......................................................XX....X...X..XX.....................X...........................................................",
"...........................................................XX...X..XX.....................X...........................................................",
"...........................................................XX....X.XX.....................XX..........................................................",
"...........................................................X.....XXXXX.XXX..XXXXXXXXXXXX.X.XX.........................................................",
"...........................................................X.....X..XX.XXXX...XXXXXXXXXX.X.XX.........................................................",
"...........................................................X.....XX.XX..XXXXX...XXXXXXX..X..X.........................................................",
"...........................................................X......XXXXX.................XXX.X.........................................................",
"...........................................................XX......X.XXX...............XXXXX..........................................................",
"...........................................................XX......XX.XXX...XXXXXXXX..XXXXXX..........................................................",
"...........................................................XX.......XXXXXXX...XXX....XXXXXXXX.........................................................",
"............................................................X........X..XXXXX.....XXXXXXXXXXX.........................................................",
"...........................................................X..........XXXXXXXXXXXXXXXXXXXXXXXX........................................................",
"...........................................................X............X..XXXXXXXX..XXXXXXXXXX.......................................................",
"..........................................................X..............X...X.........XXXXXXXXX......................................................",
"........................................................XX................XXX............XXXXXXXX.....................................................",
"........................................................X..................................XXXXXXX....................................................",
"............................................................................................XXXXXXX...................................................",
".............................................................................................XXXXXXX..................................................",
"..............................................................................................XXXXXXX.................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
"......................................................................................................................................................",
".....X........................................................................................................................................X.......",
"....XX........................................................................................................................................X.......",
"....X..........................................................................................................................................X......",
"...X...........................................................................................................................................XX.....",
"..XX.............................................................................................................................XX.............XX....",
".X...............X.................................................................................................................XX............X....",
"X..............XX....................................................................................................................X............X.X.",
"..............X.......................................................................................................................X............X.X",
"X...........XX.........................................................................................................................X..........XX.X",
"X..XX.....XXX..........................................................................................................................XX.....XX..X...",
"XXX.X.....X.............................................................................................................................X.....X.XXX...",
"X...X...XX..............................................................................................................................XX...XX...X...",
"....X...X.................................................................................................................................XXXXX....XXX",
"...XX.XX...................................................................................................................................XX.XX......",
"..XXXXX.......................................................................................................................................XXX.....",
"XXX.............................................................................................................................................XXXXXX",
"..X.............................................................................................................................................X.....",
"XXXXX.........................................................................................................................................XXXXX...",
"XXXX.X..XXX..................................................................................................................................X.....XXX",
"....XXXXXXXX..........................................................................................................................XX....XX...XXXX.",
".......X...XX........................................................................................................................XXXXXXXXX..XX....",
"XXXXXX..X...XX......................................................................................................................XX....XX.XXXX..XXX",
"XXXXXXX..X..XX......................................................................................................................X....XX...XX..XXXX",
"..........X..X.....................................................................................................................XX....X....X.......",
"...........X..XX...................................................................................................................XX...XXXXXXX.......",
"...........X...XX.................................................................................................................XX....X...XX........",
"XXXXXXXXXX.X.....XX..............................................................................................................XX....XX...XX.XXXXXXX",
"XXXXXXXXXX.XX......XX............................................................................................................X...XX.X..XX..X.XXXXX",
"XXXXXXXXXX..X...................................................................................................................X...XXX.XXXXX..X..XXXX",
"............X.................................................................................................................XX....X...X..XX........."
};
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: color.c: X11Compliance vs. XPMCompliance

Post by magick »

Use Gray90. We'll add white as a compliant color by sometime tomorrow. Thanks.
Post Reply