Specifications for jrawio 2.0
Traditionally, jrawio has been always designed as two separate modules:
- jrawio is the core and provides the codecs for reading raster bits and metadata;
- reajent is seen as a plugin of jrawio and is able to postprocess the rasters to get a renderable image.
reajent activates automatically when added in the classpath. The rationale about two separate modules was to allow people to use jrawio as both a ready-to-use library that just needed to be plugged into an existing application (by adding the jar files to the classpath) and as the base for custom image manipulation, in contexts where users developed their own postprocessors.
With version 1.6 a number of new features are going to be released:
- jrawio will be released as a single jar file
- it will be possible to specify with optional parameters whether the postprocessor must be activated or not
- it will be possible to control the postprocessor even with system properties, to allow the integration in existing applications without having to write new code.
For programmatic control a new subclass of ImageReadParam is introduced: RAWImageReadParam. It can be passed as an optional argument of ImageReader.read() as in the following examples:
imageReader.read(0, new RAWImageReadParam(Source.PROCESSED_IMAGE)) | The postprocessor is enabled - this will happen by default in jrawio 1.6; this behaviour equals the pre-1.6 behaviour when both jrawio and reajent are put in the classpath. |
imageReader.read(0, new RAWImageReadParam(Source.RAW_IMAGE)) | The postprocessor is disabled and the raw bits are returned - this equals the pre-1.6 behaviour when only jrawio was in the classpath. |
imageReader.read(0, new RAWImageReadParam(Source.FULL_SIZE_PREVIEW)) | A full-size preview is returned in place of the original image. Full-size previews are a special kind of thumbnail that are as large as the original image and are provided by many recent camera models. Loading a preview is much faster than loading and postprocessing a raw image and could be useful in some application. An exception is thrown if a full-size preview is not found. |
When no RAWImageReadParam or an empty RAWImageReadParam() is passed to read(), Source.PROCESSED_IMAGE is taken as default.
In many cases one might want to integrate jrawio in an existing application without writing new code, thus taking advantage of the fact that jrawio complies with the Image I/O API. In this case it is possible to still control the postprocessor by defining some system properties e.g. from the command line:
-Dit.tidalwave.imageio.raw.defaultSource=image | means that the default is PROCESSED_IMAGE |
-Dit.tidalwave.imageio.raw.defaultSource=rawImage | means that the default is RAW_IMAGE |
-Dit.tidalwave.imageio.raw.defaultSource=fullSizePreview | means that the default is FULL_SIZE_PREVIEW |
For consistency, the behaviour of imageReader.getWidth() and imageReader.getHeight() takes into account the selected source: this means that when PROCESSED_IMAGE is selected, the returned size is the one of the processed image, usually smaller than the sensor size (for instance, 6048 x 4032 for a Nikon D3x image). When RAW_IMAGE is selected, since the returned raster are the raw bits from the sensor, the size of the sensor is returned (for instance, 6080 x 4044 for a Nikon D3x).
This behaviour is consistent with jrawio pre-1.6. Unfortunately, the Image I/O API does not allow to pass an ImageReadParam when reading metadata (that is only allowed in the read() method). For this reason, an extension to the API is provided:
ImageReader imageReader = ... ((RAWImageReader)ir).setDefaultReadParam(readParam);
In this way, the readParam is applied to all the operations on the same ImageReader, thus including getWidth() and getHeight(). Also, in this case you don't need to specify the readParam again in imageReader.read().
Please direcy any feedback to:
users AT jrawio DOT kenai DOT com