int lastDotPos = fname.lastIndexOf( "." );
if ( lastDotPos <= 0 || lastDotPos >= fname.length()-1 ) {
throw new IOException( "Cannot determine file type extension of " + imageFile.getAbsolutePath() );
}
PhotovaultImageFactory imageFactory = new PhotovaultImageFactory();
PhotovaultImage img = null;
try {
/*
Do not read the image yet since setting raw conversion
parameters later may force a re-read.
*/
img = imageFactory.create(imageFile, false, false);
} catch (PhotovaultException ex) {
log.error( ex.getMessage() );
}
img.setCropBounds( this.getCropBounds() );
img.setRotation( prefRotation - original.getRotated() );
if ( channelMap != null ) {
img.setColorAdjustment( channelMap );
}
if ( img instanceof RawImage ) {
RawImage ri = (RawImage) img;
if ( rawSettings != null ) {
ri.setRawSettings( rawSettings );
} else if ( rawSettings == null ) {
// No raw settings for this photo yet, let's use
// the thumbnail settings
rawSettings = ri.getRawSettings();
txw.lock( rawSettings, Transaction.WRITE );
}
}
if ( width > 0 ) {
exportImage =img.getRenderedImage( width, height, false );
} else {
exportImage =img.getRenderedImage( 1.0, false );
}
} catch ( Exception e ) {
log.warn( "Error reading image: " + e.getMessage() );
txw.abort();
throw new PhotovaultException( "Error reading image: " + e.getMessage(), e );