Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading RAW images from Java

Canon/Nikon/other cameras save raw output of their sensor in some of their proprietary formats (.CR2, whatever). Is there any Java library designed to read them and convert into manageable BufferedImages?

I don't reqlly care here about fully customizable conversion similar to ufraw or imagemagick, rather something simple that "just works" for rendering simple previews of such images.

like image 732
Marcin Avatar asked Aug 03 '09 13:08

Marcin


2 Answers

I've been where you are, and I feel for you. Your best bet is to use an Adobe or dcraw-based program to create thumbnails automatically. Temporary DNG files using Adobe's converter may be easier to use.

IF you insist on doing it in Java, you're about to run into a mountain of pain. RAW formats change often, have all sorts of crazy nuances and are intentionally hard to work with. Camera makers want you to use THEIR RAW conversion software, to show the camera's abilities at its best and screw Adobe. The guy behind dcraw found that some are camera manufacturers even use encryption now!

The existing Java libraries are poor -- JRawIO has improved since I last looked at it, but it supports only a fraction of the formats that dcraw does. In addition to the listed libraries, the imagero library may provide the ability to display a thumbnail for your image.

From personal experience, don't even think about writing your own RAW file reader. I tried to do this with a very simple RAW format once (just a solid array of sensor data, 12 bits per pixel). The dcraw source translates badly to Java. You haven't seen such a nightmare of bit-fiddling ever. Took me days to debug problems with byte alignment and endian-ness.

like image 53
BobMcGee Avatar answered Oct 06 '22 23:10

BobMcGee


jrawio is a plugin for Java Image I/O. With it you can read the raster data, the thumbnails and the metadata from the raw image file.

like image 42
D. Wroblewski Avatar answered Oct 07 '22 00:10

D. Wroblewski