Reputation: 13
I found that commons imaging library fits my needs best of all, but there is a lack samples of this library usage. Does anyone have an example how to rotate jpeg image lossless (i.e. by changing file metadata only)? Thanks!
Upvotes: -1
Views: 1350
Reputation: 410
See the answer to this question on how to add/remove meta data using the Commons Imaging library.
The tag you would want to set is org.apache.commons.imaging.formats.tiff.constants.TiffTagConstants#TIFF_TAG_ORIENTATION
.
Upvotes: 0
Reputation: 3
There is a class RotatedIcon (see links) that can be used like this
if (imageOrientation.equals("3")) {
rotatedIcon = new RotatedIcon(imageIcon, RotatedIcon.Rotate.UPSIDE_DOWN);
} else if (imageOrientation.equals("6")) {
rotatedIcon = new RotatedIcon(imageIcon, RotatedIcon.Rotate.DOWN);
} else if (imageOrientation.equals("8")) {
rotatedIcon = new RotatedIcon(imageIcon, RotatedIcon.Rotate.UP);
}
imageOrientation is a property of image meta data (e.g. EXIF)
https://tips4java.wordpress.com/2009/04/06/rotated-icon/
Upvotes: 0