Raw RGB conversion

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
tioui

Raw RGB conversion

Post 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 :)
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Raw RGB conversion

Post by magick »

Add -depth 8 to your command line.
tioui

Re: Raw RGB conversion

Post 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 :)
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Raw RGB conversion

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

Re: Raw RGB conversion

Post by tioui »

Ok! Thanks again. And congratulation for your tools. It's very impressive.

Louis M :)
Post Reply