skip to Main Content

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


  1. In ImageMagick you use the -size and -depth arguments with the qualifier of GRAY or RGB depending upon if your file is grayscale or color. So

    convert -size WIDTHxHEIGHT -depth 8 GRAY:inputname.suffix outputname.newsuffix
    

    newsuffix might be gif, tif, png, jpg, etc. suffix may or may not exist, but could be bin or something else.

    But you will need to have dcraw or ufraw depending upon your OS compiled on your system, since ImageMagick uses those to do the work. You could also use those standalone without ImageMagick

    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search