} catch (IOException ioe) {
throw new IOException("Error while aligning ICC stream: " + ioe.getMessage());
}
}
ICC_Profile iccProfile = null;
try {
iccProfile = ICC_Profile.getInstance(iccStream.toByteArray());
if (log.isDebugEnabled()) {
log.debug("JPEG has an ICC profile: " + iccProfile.toString());
}
} catch (IllegalArgumentException iae) {
log.warn("An ICC profile is present in the JPEG file but it is invalid ("
+ iae.getMessage() + "). The color profile will be ignored. ("
+ info.getOriginalURI() + ")");
return null;
}
if (iccProfile.getNumComponents() != colorSpace.getNumComponents()) {
log.warn("The number of components of the ICC profile ("
+ iccProfile.getNumComponents()
+ ") doesn't match the image ("
+ colorSpace.getNumComponents()
+ "). Ignoring the ICC color profile.");
return null;
} else {