protected static void initOptions( ImageFileExportOptions options,
ImageInfo imageInfo,
Dimension saveSize )
throws IOException, LightCraftsException
{
final ImageMetadata metadata = imageInfo.getMetadata();
final ImageType t = imageInfo.getImageType();
options.setExportFile( imageInfo.getFile() );
try {
final ICC_Profile profile = t.getICCProfile( imageInfo );
if ( profile != null ) {
final String profileName =
ColorProfileInfo.getNameOf( profile );
options.colorProfile.setValue( profileName );
}
}
catch ( LightCraftsException e ) {
// use ImageExportOptions' default color profile
}
catch ( IOException e ) {
// use ImageExportOptions' default color profile
}
options.originalWidth.setValue( metadata.getImageWidth() );
options.originalHeight.setValue( metadata.getImageHeight() );
options.resizeWidth.setValue( saveSize.width );
options.resizeHeight.setValue( saveSize.height );
final double resolution = metadata.getResolution();
final int resolutionUnit = metadata.getResolutionUnit();
if ( resolution > 0 && resolutionUnit != RESOLUTION_UNIT_NONE ) {
options.resolution.setValue( (int)resolution );
options.resolutionUnit.setValue( resolutionUnit );
}
if ( options instanceof TIFFImageType.ExportOptions ) {
final TIFFImageType.ExportOptions tiffOptions =
(TIFFImageType.ExportOptions)options;
final int bitsPerChannel = metadata.getBitsPerChannel();
if ( bitsPerChannel > 0 )
tiffOptions.bitsPerChannel.setValue( bitsPerChannel );
}
}