Page 1 of 1

Raw RGB conversion

Posted: 2010-01-08T19:27:32-07:00
by tioui
Hi! When I try to convert a PNG file (say file1.png) to a RGB file (say file2.rgb) and reconvert the RGB file (file2.rgb) to a PNG file (say file3.png), the two PNG file (file1.png and file3.png) are different. Here is the command line I'm using.

Code: Select all

$ identify file1.png
      file1.png PNG 534x356 534x356+0+0 8-bit DirectClass 407kb
$ convert -size "534x356" file1.png file2.rgb
$ convert -size "534x356" file2.rgb file3.png
$ convert --version
      Version: ImageMagick 6.5.1-0 2009-08-27 Q16 OpenMP http://www.imagemagick.org
      Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC
In the file3.png, the colors are wrong, the image is split in two and is too small. I put the files on my web site. So, if you want to see for yourself.

http://www.happycat.ca/tioui/file1.png
http://www.happycat.ca/tioui/file2.rgb
http://www.happycat.ca/tioui/file3.png

I'm on Linux Ubuntu 9.10 (The Karmic Koala) 32 bits.

Thanks for your time!

Louis M :)

Re: Raw RGB conversion

Posted: 2010-01-08T19:45:57-07:00
by magick
Add -depth 8 to your command line.

Re: Raw RGB conversion

Posted: 2010-01-08T20:17:18-07:00
by tioui
Thanks magick! It works! But, if it is not too much to ask, why convert encode rgb file in depth 8 and decode in another depth?

And Sorry, it was not a bug after all!

Louis M :)

Re: Raw RGB conversion

Posted: 2010-01-09T08:06:27-07:00
by magick
Your original image depth is 8 so ImageMagick writes an 8-bit raw file. However, since its a raw file, when reading, ImageMagick does not know what depth the raw file is (no header to tell it) so it defaults to 16-bits. An easy fix is to specify the depth from the command line with -depth.

Re: Raw RGB conversion

Posted: 2010-01-09T08:28:54-07:00
by tioui
Ok! Thanks again. And congratulation for your tools. It's very impressive.

Louis M :)