Search in sources :

Example 1 with JpegImageMetadata

use of org.apache.sanselan.formats.jpeg.JpegImageMetadata in project iNaturalistAndroid by inaturalist.

the class ImageUtils method getSanselanOutputSet.

private static TiffOutputSet getSanselanOutputSet(File jpegImageFile, int defaultByteOrder) throws IOException, ImageReadException, ImageWriteException {
    TiffImageMetadata exif = null;
    TiffOutputSet outputSet = null;
    IImageMetadata metadata = Sanselan.getMetadata(jpegImageFile);
    JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata;
    if (jpegMetadata != null) {
        exif = jpegMetadata.getExif();
        if (exif != null) {
            outputSet = exif.getOutputSet();
        }
    }
    // keep all other existing tags
    if (outputSet == null)
        outputSet = new TiffOutputSet(exif == null ? defaultByteOrder : exif.contents.header.byteOrder);
    return outputSet;
}
Also used : TiffOutputSet(org.apache.sanselan.formats.tiff.write.TiffOutputSet) TiffImageMetadata(org.apache.sanselan.formats.tiff.TiffImageMetadata) JpegImageMetadata(org.apache.sanselan.formats.jpeg.JpegImageMetadata) IImageMetadata(org.apache.sanselan.common.IImageMetadata)

Example 2 with JpegImageMetadata

use of org.apache.sanselan.formats.jpeg.JpegImageMetadata in project iNaturalistAndroid by inaturalist.

the class ImageUtils method getSanselanOutputSet.

private static TiffOutputSet getSanselanOutputSet(InputStream stream, int defaultByteOrder) throws IOException, ImageReadException, ImageWriteException {
    TiffImageMetadata exif = null;
    TiffOutputSet outputSet = null;
    IImageMetadata metadata = Sanselan.getMetadata(stream, null);
    JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata;
    if (jpegMetadata != null) {
        exif = jpegMetadata.getExif();
        if (exif != null) {
            outputSet = exif.getOutputSet();
        }
    }
    // keep all other existing tags
    if (outputSet == null)
        outputSet = new TiffOutputSet(exif == null ? defaultByteOrder : exif.contents.header.byteOrder);
    return outputSet;
}
Also used : TiffOutputSet(org.apache.sanselan.formats.tiff.write.TiffOutputSet) TiffImageMetadata(org.apache.sanselan.formats.tiff.TiffImageMetadata) JpegImageMetadata(org.apache.sanselan.formats.jpeg.JpegImageMetadata) IImageMetadata(org.apache.sanselan.common.IImageMetadata)

Aggregations

IImageMetadata (org.apache.sanselan.common.IImageMetadata)2 JpegImageMetadata (org.apache.sanselan.formats.jpeg.JpegImageMetadata)2 TiffImageMetadata (org.apache.sanselan.formats.tiff.TiffImageMetadata)2 TiffOutputSet (org.apache.sanselan.formats.tiff.write.TiffOutputSet)2