Page 1 of 1
convert to RGB565 from different PNG files
Posted: 2012-09-11T08:41:15-07:00
by lekaleka
Hi all,
whenever i convert a png that i created with GIMP to a rgb565 format using ffmpeg, it works perfectly.
But whenever i create a PNG using the PHP - imagemagick ($image->newImage(800, 600, $pixel); , i get an error converting it to rgb565 that says :
" test.png: could not find codec parameters "
can anyone please help,
lekaleka
Re: convert to RGB565 from different PNG files
Posted: 2012-09-11T09:14:45-07:00
by fmw42
Re: convert to RGB565 from different PNG files
Posted: 2012-09-11T09:34:38-07:00
by lekaleka
Hi,
thanks for the quick reply.
this is my command line in ffmpeg :
ffmpeg -vcodec png -i test.png -vcodec rawvideo -f rawvideo -pix_fmt rgb565 test.raw
with im i did only :
convert test.png +dither -colors 256 -define png:bit-depth=5 test1.png
Re: convert to RGB565 from different PNG files
Posted: 2012-09-11T09:35:40-07:00
by lekaleka
i use ubuntu 12.04 64bit
imagemagick 6.7.9
with the im command i get this error:
convert: ignoring invalid defined png:bit-depth =5 @ warning/png.c/WritePNGImage/10315.
Just a gentle reminder: with converting a GIMP png file i have no problems, it is only with the png that i create with PHP imagemagick library
Re: convert to RGB565 from different PNG files
Posted: 2012-09-11T09:46:56-07:00
by lekaleka
Thanks fmw42,
it worked with this command :
convert test.png -ordered-dither threshold,32,64,32 color_565.png
Thanks anyways

Re: convert to RGB565 from different PNG files
Posted: 2012-09-11T10:50:18-07:00
by fmw42
see
http://www.imagemagick.org/Usage/formats/#png_write for details of PNG write controls and bit-depth. There are some caveats.
My guess is that IM write controls for PNG do not allow bit-depth of 5. Your bit depth even with 565 format is still 16 bit depth, I believe. But I am not an expert on this.
Glennrp would have to respond with comments as he is the PNG expert for IM.
Re: convert to RGB565 from different PNG files
Posted: 2012-09-13T05:38:38-07:00
by glennrp
fmw42 wrote:Glennrp would have to respond with comments as he is the PNG expert for IM.
The PNG spec allows only 8 and 16 bits per sample for truecolor images, 1,2,4, or 8 for the indexes in indexed color images and 1, 2, 4, 8, or 16 for the samples in grayscale images. You can use "ordered-dither threshold" as you did to reduce the image precision to 5-6-5 but it's still written as 8-8-8 (or with 8-bit indexes, if 256 or fewer colors are present)
Edit: removed comment about ordered-dither producing a 1-1-1 image; the "levels" feature of ordered-dither was added since I last worked on it.