Trouble with 8-bit PNG output

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
klonuo
Posts: 4
Joined: 2011-03-23T17:11:09-07:00
Authentication code: 8675308

Trouble with 8-bit PNG output

Post by klonuo »

Hi
I'm using ImageMagick-6.6.8-6-Q16-windows-dll.exe

I have large JPEG images and wanted to batch resize to PNG:

Code: Select all

convert.exe -geometry 704x576! -quality 100 in.jpg png8:out.png
This command produces 8-bit PNG as I would expect, but I have problem when I try to pass this 8-bit PNG to png2yuv (from mjpegtools-1.9.0-mingw-bin.tar.bz2)

This is the error:
**ERROR: [png2yuv.exe] mpegz: UNKNOWN COLOR FORMAT 3 in PNG transformation !
Googling around I found that I can define color format for IM PNG output, and thought to try that:

Code: Select all

convert.exe -geometry 704x576! -quality 100 in.jpg -define png:color-type=2 png8:out.png
But this (and similar variations) gives me yet other error:
Magick: unable to open image `color-type=2': No such file or directory @ error/blob.c/OpenBlob/2587.
Magick: unable to open file `color-type=2' @ error/png.c/ReadPNGImage/3054.
Then I thought to ask fo help :)

Thanks in advance
klonuo
Posts: 4
Joined: 2011-03-23T17:11:09-07:00
Authentication code: 8675308

Re: Trouble with 8-bit PNG output

Post by klonuo »

I found a way to produce valid 8-bit PNG so that libpng would understand it: In the ocean of command line switches there is PNG24: instead PNG8: which would produce 8-bit PNG in RGB mode instead in indexed colors
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: Trouble with 8-bit PNG output

Post by glennrp »

Yes, PNG24: is the easiest way to get what you need.

It looks as though the "png:" in the "-define" option is being
interpreted as a windows drive. You could try putting
quotes (I forget whether single or double is required, try
both) around the "png:color-type=2"

I'm not sure what is supposed to happen when you
both define the color-type=2 and use PNG8: which
is equivalent to -define PNG:color-type=3. I believe
the PNG8: takes precedence.

I dpn't think it's libpng that can't read the indexed-color
format (after all, libpng wrote it) but png2yuv.
klonuo
Posts: 4
Joined: 2011-03-23T17:11:09-07:00
Authentication code: 8675308

Re: Trouble with 8-bit PNG output

Post by klonuo »

Yes, problem was that I run that command as part of batch file with "Enabled Delayed Expansion" so I needed to escape some characters, but - running on command prompt it raised error about not being able to write color-type 2 for PNG8: and if I omit PNG8: then it would write 24-bit PNG. I feed it with -depth 8, or -colors 256 and what not, till I accidentally run on PNG24: option.

About libpng, it was a kind of humor as png2yuv.exe states:
Any 8bit PNG format supported by libpng can be read.
Post Reply