* @throws IOException if there was a problem reading the image file.
*/
private ImageMetaDataBuilder createImageMetaData(File imageFile)
throws IOException {
ImageMetaDataBuilder builder;
// Calculate the extension for this image.
String imageName = imageFile.getName();
String extension = getExtension(imageName);
if (extension != null) {
// And figure out the official encoding for this extension.
ImageEncoding encoding = (ImageEncoding)
ImageEncoding.COLLECTION.getEncodingForExtension(extension);
// If we support this extension
if (encoding != null) {
// Then read in the image...
RenderedImage image = javax.imageio.ImageIO.read(imageFile);
ColorModel color = image.getColorModel();
// ... create the metaData ...
builder = factory.createImageMetaDataBuilder();
// ... and then use the image meta data to populate it.
builder.setWidth(image.getWidth());
builder.setHeight(image.getHeight());
builder.setPixelDepth(color.getPixelSize());
ImageRendering rendering;
// todo pixel size is not enough, sometime there are levels of gray.
if (color.getPixelSize() > 1) {
rendering = ImageRendering.COLOR;
} else {
rendering = ImageRendering.GRAYSCALE;
}
builder.setRendering(rendering);
builder.setImageEncoding(encoding);
if (logger.isDebugEnabled()) {
logger.debug("Created metaData: " + builder);
}
} else {