xc:color -scale NxM results in xpm output with N*M colors

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
canavan
Posts: 23
Joined: 2013-02-18T10:12:03-07:00
Authentication code: 6789

xc:color -scale NxM results in xpm output with N*M colors

Post by canavan »

Creating a monochrome image with xc, scaling it to an arbitrary size and saving as an XPM results in an output file with as many palette / colormap entries as pixels, each used only once in the image. As an example, a 16x16 image scaled from a 1x1 'red' xc: canvas would have 256 colormap entries, all red. A smaller example:

Code: Select all

convert xc:red -scale 2x2 red.xpm
results in:

Code: Select all

/* XPM */
static char *red[] = {
/* columns rows colors chars-per-pixel */
"2 2 4 1 ",
"  c red",
". c red",
"X c red",
"o c red",
/* pixels */
" .",
"Xo"
};
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: xc:color -scale NxM results in xpm output with N*M colors

Post by snibgo »

Please, always mention your IM version and platform.

"-scale" isn't relevant. The same behaviour occurs with a sized canvas. IM v6.9.2-5 on Windows 8.1.

Code: Select all

convert -size 2x2 xc:red red.xpm

Code: Select all

/* XPM */
static char *red[] = {
/* columns rows colors chars-per-pixel */
"2 2 4 1 ",
"  c red",
". c red",
"X c red",
"o c red",
/* pixels */
" .",
"Xo"
};
snibgo's IM pages: im.snibgo.com
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: xc:color -scale NxM results in xpm output with N*M colors

Post by magick »

Thanks for the problem report. We can reproduce it and will have a patch to fix it in GIT master branch @ https://github.com/ImageMagick/ImageMagick later today. The patch will be available in the beta releases of ImageMagick @ http://www.imagemagick.org/download/beta/ by sometime tomorrow.
canavan
Posts: 23
Joined: 2013-02-18T10:12:03-07:00
Authentication code: 6789

Re: xc:color -scale NxM results in xpm output with N*M colors

Post by canavan »

Please, always mention your IM version and platform.
I did build the current release (6.9.3-7) just to verify, the problem exists at least since 6.8.9-9 as shipped with Ubuntu 15.10.

While -scale and -size both produce images that have the problem, an image created with -xc:red[16x16] does not.
Post Reply