Page 1 of 1

How can I write out grayscale 16 bit raw files?

Posted: 2008-10-01T09:41:54-07:00
by simon
Hi,
I have a script that uses convert to process some png files into raw files.

This used to work

Code: Select all

convert foo.png -depth 16 r:bar.raw
but now when I run it convert doesn't generate a file.

if I do this

Code: Select all

convert foo.png -depth 16 bar.raw
it makes a file but in png format not raw - renaming the output to bar.png allows me to open it.

if I do this

Code: Select all

convert foo.png -depth 16 rgb:bar.raw
I correctly get a raw file but it is rgb not grayscale.

So what is going on here, and how do you generate 16 bit grayscale raw files using convert these days?

Re: How can I write out grayscale 16 bit raw files?

Posted: 2008-10-01T09:56:36-07:00
by magick
We're using ImageMagick 6.4.4-1, the latest release, these commands work as expected (creates 16-bit gray image of the red channel):
  • convert logo: -interlace none -depth 16 r:bar.raw
    display -size 640x480 -interlace none -depth 16 gray:bar.raw
Do these commands work for you?

Re: How can I write out grayscale 16 bit raw files?

Posted: 2008-10-01T10:02:32-07:00
by simon
I'm using the same version on windows and when I run that command no file is generated.
No errors but no output file.
Changing to rgb:bar.raw generates a file, but not the format I want.

When I run my script I get this error

convert: unable to open image `r:1.raw': No such file or directory

Again changing to rgb: means that files are generated but in the wrong format.

Re: How can I write out grayscale 16 bit raw files?

Posted: 2008-10-01T10:07:27-07:00
by magick
We tried these commands under Windows, ImageMagick 6.4.4-1, and they worked as expected:
  • convert logo: -interlace none -depth 16 r:bar.raw
    convert -size 640x480 -interlace none -depth 16 gray:bar.raw bar.png
We're not sure why its failing for you.

Re: How can I write out grayscale 16 bit raw files?

Posted: 2008-10-01T10:09:49-07:00
by simon
if I do this

convert foo.png -depth 16 gray:bar.raw

I get a grayscale 16 bit raw file but when I open it the image is scrambled.

Damn this is annoying.

Re: How can I write out grayscale 16 bit raw files?

Posted: 2008-10-01T10:18:50-07:00
by simon
Is your input file a 16 bit grayscale png?

Re: How can I write out grayscale 16 bit raw files?

Posted: 2008-10-01T10:23:59-07:00
by simon
Ah! this does work

Code: Select all

convert foo.png -depth 16 gray:bar.raw
but I have to open with IBM byte order.

Re: How can I write out grayscale 16 bit raw files?

Posted: 2008-10-01T10:27:38-07:00
by magick
You can specify the byte order with the -endian option.

Re: How can I write out grayscale 16 bit raw files?

Posted: 2008-10-01T10:48:45-07:00
by simon
cheers that should do it

Re: How can I write out grayscale 16 bit raw files?

Posted: 2008-10-02T09:33:39-07:00
by simon
I found the problem.

I had a drive mapped to R: so instead of it using the raw format it wrote the file to the R: drive, something to look at perhaps.... :)

Re: How can I write out grayscale 16 bit raw files?

Posted: 2008-10-02T10:06:16-07:00
by magick
You can work around the conflict with filenames like r:image.r or raw:image.r. See if that works.