if ( colorSpace == CS_UNKNOWN )
throw new LCImageLibException(
"Unsupported number of components: " + numComponents
);
final LCJPEGWriter writer = new LCJPEGWriter(
options.getExportFile().getPath(),
image.getWidth(), image.getHeight(),
numComponents, colorSpace,
jpegOptions.quality.getValue(),
jpegOptions.resolution.getValue(),
jpegOptions.resolutionUnit.getValue()
);
ICC_Profile profile = ColorProfileInfo.getExportICCProfileFor(
jpegOptions.colorProfile.getValue()
);
if ( profile == null )
profile = JAIContext.sRGBExportColorProfile;
writer.setICCProfile( profile );
if ( lznDoc != null ) {
final byte[] buf = XMLUtil.encodeDocument( lznDoc, false );
writer.writeSegment( JPEG_APP4_MARKER, buf );
}
writer.putMetadata( metadata );
writer.putImage( image, thread );
}
catch ( LCImageLibException e ) {
final IOException ioe = new IOException( "JPEG export failed" );
ioe.initCause( e );
throw ioe;