////////// Core directory
final ImageMetadataDirectory coreDir =
metadata.getDirectoryFor( CoreDirectory.class );
final ImageMetaValue orientation =
coreDir.getValue( CORE_IMAGE_ORIENTATION );
if ( orientation != null && (orientation.isEdited() || xmpExists) ) {
final ImageOrientation xmpOrientation = xmpMetadata != null ?
xmpMetadata.getOrientation() : ORIENTATION_UNKNOWN;
modifyMetadata(
imageInfo, EXIF_ORIENTATION, orientation.getShortValue(),
xmpOrientation != ORIENTATION_UNKNOWN ?
xmpOrientation.getTIFFConstant() : NO_META_VALUE,
false
);
orientation.clearEdited();
}
final ImageMetaValue rating = coreDir.getValue( CORE_RATING );
if ( rating != null && (rating.isEdited() || xmpExists) ) {
final short xmpRating = xmpMetadata != null ?
(short)xmpMetadata.getRating() : NO_META_VALUE;
final short newRating = rating.getShortValue();
boolean removeRating = false;
if ( newRating == 0 ) {
metadata.removeValues( CoreDirectory.class, CORE_RATING );
metadata.removeValues( SubEXIFDirectory.class, EXIF_MS_RATING );
removeRating = true;
}
modifyMetadata(
imageInfo, EXIF_MS_RATING, newRating, xmpRating, removeRating
);
rating.clearEdited();
}
// TODO: must do something about unrating a photo
////////// IPTC directory