Re: convert taking a grayscale image and turning it into RGB

"Viktor Ivanov" <[email protected]>
Newsgroups gmane.comp.video.image-magick.bugs
Message-ID <[email protected]>
>
> > The pnm is RGB!
>
> PNM supports monochrome, grayscale, and RGB but not colormapped.  To
> force a colormapped image use -type Palette:
>
>  convert mottle.pnm -type Palette ...
>

That does not explain why the behavior changed from the old version to
the new version. Furthermore, I tried using -type several different
ways but the result was always the same as before - the grayscale png
turned into an rgb pnm.

I was quite unhappy with that behavior and set out to explore what was
going on with gdb and promptly found a bug! A break; was missing from
one of the cases in coders/pnm.c which meant that all pnms were
turning into type 6 because the default on the switch would always be
executed. Here's the fix for it:

diff --git a/coders/pnm.c b/coders/pnm.c
index b7caf77..278e857 100644
--- a/coders/pnm.c
+++ b/coders/pnm.c
@@ -1259,6 +1259,7 @@ static MagickBooleanType WritePNMImage(const
ImageInfo *image_info,Image *image)
                   format='1';
               }
           }
+        break;
       }
       default:
       {

I rebuilt the code with that fix and tested. convert did the right thing! YAY!

-- 
Viktor R. Ivanov <[email protected]>

P.S.
I couldnt check the code out of svn. Kept getting:
svn: PROPFIND request failed on '/subversion/ImageMagick/trunk'
svn: PROPFIND of '/subversion/ImageMagick/trunk': 405 Method Not
Allowed (https://www.imagemagick.org)

So.. the patch I created is based off of the 6.4.1 tar off on of the
download mirrors
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.