convert to RGB565 from different PNG files

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
lekaleka
Posts: 4
Joined: 2012-09-11T08:32:52-07:00
Authentication code: 67789

convert to RGB565 from different PNG files

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert to RGB565 from different PNG files

Post by fmw42 »

what is your exact IM command? and what version of IM and platform?

see
viewtopic.php?f=1&t=8072&p=82506&hilit= ... mat#p82506
viewtopic.php?f=2&t=17425&p=65405&hilit ... mat#p65405
lekaleka
Posts: 4
Joined: 2012-09-11T08:32:52-07:00
Authentication code: 67789

Re: convert to RGB565 from different PNG files

Post 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
lekaleka
Posts: 4
Joined: 2012-09-11T08:32:52-07:00
Authentication code: 67789

Re: convert to RGB565 from different PNG files

Post 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
lekaleka
Posts: 4
Joined: 2012-09-11T08:32:52-07:00
Authentication code: 67789

Re: convert to RGB565 from different PNG files

Post by lekaleka »

Thanks fmw42,

it worked with this command :

convert test.png -ordered-dither threshold,32,64,32 color_565.png

Thanks anyways :)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert to RGB565 from different PNG files

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

Re: convert to RGB565 from different PNG files

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