Converting multiple png to mng

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
npostavs
Posts: 3
Joined: 2012-06-03T17:48:35-07:00
Authentication code: 13

Converting multiple png to mng

Post 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
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: Converting multiple png to mng

Post 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.
npostavs
Posts: 3
Joined: 2012-06-03T17:48:35-07:00
Authentication code: 13

Re: Converting multiple png to mng

Post 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
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: Converting multiple png to mng

Post 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.
npostavs
Posts: 3
Joined: 2012-06-03T17:48:35-07:00
Authentication code: 13

Re: Converting multiple png to mng

Post 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)
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: Converting multiple png to mng

Post 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.
Post Reply