Specifications for jrawio 3.0
This is a *very* preliminary draft.
jrawio so far has been primarily focused in decoding the raw bits from files and getting the metadata; the "reajent" component, that has got the responsibility of "developing" the raw file into a final result, has only been partially implemented and - above all - has got no quality assurance for the results - I mean, there are tests to check that a result is produced, but there's nothing about the accuracy of color rendering, etc... Furthermore, by the very nature of camera raw files, people need often to fine tune the process of "developing", as well as possibly get results "compatible" with the outcome of popular camera raw tools such as Adobe's and Apple's ones.
So, in 3.0 the most important new group of features will be "profiles". If you'd like to have a rough idea about what they are, please have a look at the issue tracker for v3.0.
Just to have a look at code, this is a preliminary code sketch that gives you a rough idea of the new Profiles API:
final ICC_Profile ADOBE_RGB = ...
final ProfileManager profileManager = ProfileManager.getInstance();
final Profile profile = profileManager.findProfileById("dcraw").createModifiableCopy();
profile.getOperation(WhiteBalanceOp.class).setTemperature(5500);
profile.getOperation(ColorProfileOp.class).setICCProfile(ADOBE_RGB);
profile.getOperation(DeNoiseOp.class).setAdaptivePropertiesHandler(new AdaptivePropertiesHandler<DeNoiseOp>()
{
@Override
public void adaptProperties (final @Nonnull DeNoiseOp operation,
final @Nonnull ImageDescriptor imageDescriptor)
{
final Dimension dimension = imageDescriptor.getDimension();
final int width = dimension.width;
final int height = dimension.height;
operation.setAlgorithm(((width * height) >= 2 * 1024 * 1024) ? "xxx" : "yyy");
}
});
final Margins margins = Margins.create().withLeft(10).withRight(10).withTop(10).withBottom(10);
profile.getOperation(CropOp.class).setAdaptivePropertiesHandler(new MarginSetter().setMargins(margins));
final ImageReader reader = ImageIO.getImageReadersByFormatName("NEF").next();
BufferedImage img = reader.read(0, new RawImageReadParam(profile));
// Always read the RAW_DATA (default behaviour)
img = reader.read(0, new RawImageReadParam(SourceSelector.Source.RAW_DATA()));
// Always read the second thumbnail
img = reader.read(0, new RawImageReadParam(SourceSelector.Source.THUMBNAIL(1)));
// Read the first thumbnail if larger than 6 megapixels, the raw data instead
img = reader.read(0, new RawImageReadParam(new SourceSelector()
{
@Override
public Source selectSource (@Nonnull final ImageDescriptor imageDescriptor)
{
final Dimension dimension = imageDescriptor.getDimension();
final int width = dimension.width;
final int height = dimension.height;
return ((width * height) >= 6 * 1024 * 1024) ? Source.THUMBNAIL(0) : Source.RAW_DATA();
}
}));