How can I write out grayscale 16 bit raw 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
simon

How can I write out grayscale 16 bit raw files?

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

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

Post 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?
simon

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

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

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

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

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

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

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

Post by simon »

Is your input file a 16 bit grayscale png?
simon

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

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

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

Post by magick »

You can specify the byte order with the -endian option.
simon

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

Post by simon »

cheers that should do it
simon

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

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

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

Post by magick »

You can work around the conflict with filenames like r:image.r or raw:image.r. See if that works.
Post Reply