Package: imagemagick
Version: 6:6.0.6.2-2.4
Tags: patch

Hi,

I have a XPM file with more than 8464 colors (this means more than two bytes
for each pixel are used). convert fails to read this file:

convert -verbose pixmap1.xpm pixmap2.xpm
convert: Improper image header `pixmap1.xpm'.

So I also fail to reduce the colors using convert (and I do not know any
other tool for this, even gimp cannot perform this task!?):
convert -colors 92 pixmap1.xpm pixmap2.xpm

Here is a trivial patch which fixes this by accepting more bytes for each
pixel instead of the old limit 2:
--- coders/xpm.c.orig 2006-03-21 11:49:57.000000000 +0100
+++ coders/xpm.c  2006-03-21 11:49:39.000000000 +0100
@@ -275,7 +275,7 @@
     if (count == 4)
       break;
   }
-  if ((count != 4) || (width > 2) || (image->columns == 0) ||
+  if ((count != 4) || (width > 10) || (image->columns == 0) ||
       (image->rows == 0) || (image->colors == 0))
     ThrowReaderException(CorruptImageError,"ImproperImageHeader");
   image->depth=16;

It seems that one byte can represent 92 colors, 2 bytes: 92*92, ...
(at least in imagemagics implementation) so 10 bytes are really sufficient.

Now converting and color reduction work (output of -verbose):
pixmap1.xpm XPM 1270x944 1270x944+0+0 PseudoClass 10809c 3.61mb 152.020u 3:38
pixmap1.xpm=>pixmap2.xpm XPM 1270x944 1270x944+0+0 PseudoClass 10809c 3.67mb 

Jens


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to