How to use ImageMagick utilities to display/convert raw image files which do not come with any metadata inside?

Viewed 2581

I got a RAW image file (from a camera sensor module) which does not contain any metadata inside, but I know the metadata from other source, i.e., its width*height, and the depth (8-bit grey). How can I tell imagemagick utilities (convert, e.g.) to convert it to other formats?

Btw, I can open it using Photoshop (by telling it the metadata in a popup dialog), but Photoshop is not conveninent for my task at hand.

Thanks,

/bruin

2 Answers

I'm also working with raw images (as in binary files containing pixel values with no header) and fmw42's answer helped me out.

I found it tricky to figure out how to downsample the bit depth. In my case, the raw files contained 10 bits per pixel, unpacked (that is, 16 bits per pixel but only 10 bits are significant). To map that correctly to an 8 bpp output, do:

convert -size WIDTHxHEIGHT -depth 16 GRAY:inputname.suffix -level 0,1023,1.0 -depth 8 outputname.newsuffix

Without -level, all 16 bits are downsampled to 8, resulting (in my case) in what was effectively a 2 bit image stored at 8 bits per pixel.

Related