Page 1 of 1

Converting multiple png to mng

Posted: 2012-06-03T21:15:45-07:00
by npostavs
I'm having trouble converting some png files into a single mng:

Apparently putting 2 Pallete type images together that have more than 256 colours in total fails:

Code: Select all

 convert rose: -type Palette rose.png

 convert rose: -negate -type Palette neg-rose.png

 convert rose.png neg-rose.png rose-and-neg.mng

 identify rose-and-neg.mng
rose-and-neg.mng MNG 70x46 70x46+0+0 8-bit DirectClass 0.000u 0:00.000
identify.exe: Invalid colormap index `rose-and-neg.mng' @ error/image.c/SyncImage/4447.
If there are fewer colours there is no error, but then the result only has 1 image:

Code: Select all

 convert rose: -colors 100 -type Palette rose.png

 convert rose: -colors 100 -negate -type Palette neg-rose.png

 convert rose.png neg-rose.png rose-and-neg.mng

 identify rose-and-neg.mng
rose-and-neg.mng MNG 70x46 70x46+0+0 8-bit DirectClass 0.000u 0:00.000
Some experimenting with simpler images suggests that -delay 1 is needed to get multiple image in the .mng, but then a new error:

Code: Select all

 convert rose: -colors 100 -type Palette rose.png

 convert rose: -colors 100 -negate -type Palette neg-rose.png

 convert -delay 1 rose.png neg-rose.png rose-and-neg.mng

 identify rose-and-neg.mng
rose-and-neg.mng MNG 70x46 70x46+0+0 8-bit DirectClass 0.000u 0:00.001
identify.exe: image->next for first image is NULL but shouldn't be. `rose-and-neg.mng' @ error/png.c/ReadMNGImage/6807.
Also, I can't figure out how to convert from a Palette type to TrueColor:

Code: Select all

 convert rose: really-true-rose.png

 identify -verbose really-true-rose.png   | grep Type
  Type: TrueColor

 convert rose: -type Palette rose-palette.png

 identify -verbose rose-palette.png   | grep Type
  Type: Palette

 convert rose-palette.png -type TrueColor rose-true.png

 identify -verbose rose-true.png   | grep Type
  Type: Palette

Code: Select all

 identify -version
Version: ImageMagick 6.7.7-4 2012-05-29 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP

Re: Converting multiple png to mng

Posted: 2012-06-04T02:17:38-07:00
by glennrp
Failing to handle two images with a total more than 256 palette entries gracefully seems to be a bug.

Yes, you need a non-zero delay between images to get separate frames. According to the MNG spec, a sequence of images with zero delay will be combined into one frame.

Using png24:rose-true.png as the output should give you a truecolor image.

Re: Converting multiple png to mng

Posted: 2012-06-04T18:34:17-07:00
by npostavs
glennrp wrote: Failing to handle two images with a total more than 256 palette entries gracefully seems to be a bug.

Yes, you need a non-zero delay between images to get separate frames. According to the MNG spec, a sequence of images with zero delay will be combined into one frame.
But the "image->next for first image is NULL but shouldn't be. `rose-and-neg.mng' @ error/png.c/ReadMNGImage/6807." also seems to indicate a bug, no?
Using png24:rose-true.png as the output should give you a truecolor image.
Hmm, doesn't seem to work, even png32 just gives PaletteAlpha:

Code: Select all

 convert rose: -type Palette rose-palette.png

 identify -verbose rose-palette.png   | grep Type
  Type: Palette

 convert rose-palette.png png32:rose-true.png

 identify -verbose rose-true.png   | grep Type
  Type: PaletteAlpha

Re: Converting multiple png to mng

Posted: 2012-06-04T20:12:14-07:00
by glennrp
Identify tells about the image, not the formatted file. If you use "grep IHDR" or "grep png:" instead of "grep Type" you will get some information about how the PNG file was stored. "identify" figures out the type after it receives the image from the PNG decoder, which returns image_info->type==UndefinedType.

Re: Converting multiple png to mng

Posted: 2012-06-06T11:14:07-07:00
by npostavs
Okay, that makes sense. Converting Truecolour pngs works; identify -verbose lists all the scenes, but plain identify errors out.

Also, it would be nice if the IHDR listed the meaning of the number, ie
png:IHDR.color_type : 2 (Truecolour)

Re: Converting multiple png to mng

Posted: 2012-06-06T14:54:25-07:00
by glennrp
npostavs wrote: Also, it would be nice if the IHDR listed the meaning of the number, ie
png:IHDR.color_type : 2 (Truecolour)
I guess that would be simple enough. I just did that for the rendering intent recently.
[edit] This has been checked in to SVN revision 8174 for IM6 and IM7.