JPEG Autorotate is a Java library to rotate JPEG images based on EXIF orientation.
Applies the right orientation to a JPEG image, based on its EXIF tag. More precisely, it:
- Rotates the pixels
- Rotates the thumbnail, if present
- Sets the
Orientation
EXIF tag to1
(default orientation value) - Updates the following metadata values, if present:
- EXIF
ExifImageWidth
ExifImageLength
RelatedImageWidth
RelatedImageHeight
- XMP
tiff:Orientation
tiff:ImageWidth
tiff:ImageLength
exif:PixelXDimension
exif:PixelYDimension
xmp:ThumbnailsWidth
xmp:ThumbnailsHeight
- EXIF
- Retains and does not alter other metadata tags
- Currently does not support updating
MakerNotes
metadata
More information about EXIF metadata is available at:
Requires Java 8 or later
You can download source from the releases page
Alternatively, you can install the library via its Maven package
<dependency>
<groupId>com.domenicseccareccia</groupId>
<artifactId>jpeg-autorotate</artifactId>
<version>1.1.0</version>
</dependency>
The library will load an image by either a String
file path, File
or InputStream
, apply rotation, update metadata and return the image as a byte array.
File Path
byte[] image = JpegAutorotate.rotate("path/to/directory");
File
byte[] image = JpegAutorotate.rotate(new File("path/to/directory"));
InputStream
byte[] image = JpegAutorotate.rotate(new FileInputStream(new File("path/to/directory")));
The library throws the following exceptions:
JpegAutorotateException
FileNotFoundException
- Only thrown if loading image by either a
String
file path orFile
)
- Only thrown if loading image by either a
Contributions are welcome and will be fully credited.
See CONTRIBUTING.md for information on how to contribute to JPEG Autorotate.
This library uses the following libraries:
- Apache Commons Imaging, available under the Apache License v2 containing the following notices and atrtibutions.
- Apache Commons IO, available under the Apache License v2 containing the following notices and atrtibutions.
The JPEG Autorotate logo uses the following icons from Font Awesome, available under the Creative Commons Attribution 4.0 International License:
The following icon changes were made:
- Stroke width decreased for all icons by 0.25
- Detached arrows from sync-alt
This code is under the Apache License v2