Merge "Remove support for writing DNG files from ExifInterface" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
96ca825746
@@ -79,20 +79,24 @@ import java.util.zip.CRC32;
|
|||||||
/**
|
/**
|
||||||
* This is a class for reading and writing Exif tags in various image file formats.
|
* This is a class for reading and writing Exif tags in various image file formats.
|
||||||
* <p>
|
* <p>
|
||||||
|
* <b>Note:</b> This class has known issues on some versions of Android. It is recommended to use
|
||||||
|
* the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a>
|
||||||
|
* <a href="{@docRoot}reference/androidx/exifinterface/media/ExifInterface.html">ExifInterface
|
||||||
|
* Library</a> since it offers a superset of the functionality of this class and is more easily
|
||||||
|
* updateable. In addition to the functionality of this class, it supports parsing extra metadata
|
||||||
|
* such as exposure and data compression information as well as setting extra metadata such as GPS
|
||||||
|
* and datetime information.
|
||||||
|
* <p>
|
||||||
* Supported for reading: JPEG, PNG, WebP, HEIF, DNG, CR2, NEF, NRW, ARW, RW2, ORF, PEF, SRW, RAF,
|
* Supported for reading: JPEG, PNG, WebP, HEIF, DNG, CR2, NEF, NRW, ARW, RW2, ORF, PEF, SRW, RAF,
|
||||||
* AVIF.
|
* AVIF.
|
||||||
* <p>
|
* <p>
|
||||||
* Supported for writing: JPEG, PNG, WebP, DNG.
|
* Supported for writing: JPEG, PNG, WebP.
|
||||||
* <p>
|
* <p>
|
||||||
* Note: JPEG and HEIF files may contain XMP data either inside the Exif data chunk or outside of
|
* Note: JPEG and HEIF files may contain XMP data either inside the Exif data chunk or outside of
|
||||||
* it. This class will search both locations for XMP data, but if XMP data exist both inside and
|
* it. This class will search both locations for XMP data, but if XMP data exist both inside and
|
||||||
* outside Exif, will favor the XMP data inside Exif over the one outside.
|
* outside Exif, will favor the XMP data inside Exif over the one outside.
|
||||||
* <p>
|
* <p>
|
||||||
* Note: It is recommended to use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a>
|
|
||||||
* <a href="{@docRoot}reference/androidx/exifinterface/media/ExifInterface.html">ExifInterface
|
|
||||||
* Library</a> since it is a superset of this class. In addition to the functionalities of this
|
|
||||||
* class, it supports parsing extra metadata such as exposure and data compression information
|
|
||||||
* as well as setting extra metadata such as GPS and datetime information.
|
|
||||||
*/
|
*/
|
||||||
public class ExifInterface {
|
public class ExifInterface {
|
||||||
private static final String TAG = "ExifInterface";
|
private static final String TAG = "ExifInterface";
|
||||||
@@ -1294,7 +1298,6 @@ public class ExifInterface {
|
|||||||
new ExifTag(TAG_Y_CB_CR_SUB_SAMPLING, 530, IFD_FORMAT_USHORT),
|
new ExifTag(TAG_Y_CB_CR_SUB_SAMPLING, 530, IFD_FORMAT_USHORT),
|
||||||
new ExifTag(TAG_Y_CB_CR_POSITIONING, 531, IFD_FORMAT_USHORT),
|
new ExifTag(TAG_Y_CB_CR_POSITIONING, 531, IFD_FORMAT_USHORT),
|
||||||
new ExifTag(TAG_REFERENCE_BLACK_WHITE, 532, IFD_FORMAT_URATIONAL),
|
new ExifTag(TAG_REFERENCE_BLACK_WHITE, 532, IFD_FORMAT_URATIONAL),
|
||||||
new ExifTag(TAG_XMP, 700, IFD_FORMAT_BYTE),
|
|
||||||
new ExifTag(TAG_COPYRIGHT, 33432, IFD_FORMAT_STRING),
|
new ExifTag(TAG_COPYRIGHT, 33432, IFD_FORMAT_STRING),
|
||||||
new ExifTag(TAG_EXIF_IFD_POINTER, 34665, IFD_FORMAT_ULONG),
|
new ExifTag(TAG_EXIF_IFD_POINTER, 34665, IFD_FORMAT_ULONG),
|
||||||
new ExifTag(TAG_GPS_INFO_IFD_POINTER, 34853, IFD_FORMAT_ULONG),
|
new ExifTag(TAG_GPS_INFO_IFD_POINTER, 34853, IFD_FORMAT_ULONG),
|
||||||
@@ -2076,7 +2079,7 @@ public class ExifInterface {
|
|||||||
* {@link #setAttribute(String,String)} to set all attributes to write and
|
* {@link #setAttribute(String,String)} to set all attributes to write and
|
||||||
* make a single call rather than multiple calls for each attribute.
|
* make a single call rather than multiple calls for each attribute.
|
||||||
* <p>
|
* <p>
|
||||||
* This method is supported for JPEG, PNG, WebP, and DNG files.
|
* This method is supported for JPEG, PNG, and WebP files.
|
||||||
* <p class="note">
|
* <p class="note">
|
||||||
* Note: after calling this method, any attempts to obtain range information
|
* Note: after calling this method, any attempts to obtain range information
|
||||||
* from {@link #getAttributeRange(String)} or {@link #getThumbnailRange()}
|
* from {@link #getAttributeRange(String)} or {@link #getThumbnailRange()}
|
||||||
@@ -2088,11 +2091,15 @@ public class ExifInterface {
|
|||||||
* <p>
|
* <p>
|
||||||
* For PNG format, the Exif data will be stored as an "eXIf" chunk as per
|
* For PNG format, the Exif data will be stored as an "eXIf" chunk as per
|
||||||
* "Extensions to the PNG 1.2 Specification, Version 1.5.0".
|
* "Extensions to the PNG 1.2 Specification, Version 1.5.0".
|
||||||
|
* <p>
|
||||||
|
* <b>Warning:</b> Calling this method on a DNG-based instance of {@code ExifInterface} may
|
||||||
|
* result in the original image file being overwritten with invalid data on some versions of
|
||||||
|
* Android 13 (API 33).
|
||||||
*/
|
*/
|
||||||
public void saveAttributes() throws IOException {
|
public void saveAttributes() throws IOException {
|
||||||
if (!isSupportedFormatForSavingAttributes()) {
|
if (!isSupportedFormatForSavingAttributes()) {
|
||||||
throw new IOException("ExifInterface only supports saving attributes for JPEG, PNG, "
|
throw new IOException("ExifInterface only supports saving attributes for JPEG, PNG, "
|
||||||
+ "WebP, and DNG formats.");
|
+ "and WebP formats.");
|
||||||
}
|
}
|
||||||
if (mIsInputStream || (mSeekableFileDescriptor == null && mFilename == null)) {
|
if (mIsInputStream || (mSeekableFileDescriptor == null && mFilename == null)) {
|
||||||
throw new IOException(
|
throw new IOException(
|
||||||
@@ -2150,10 +2157,6 @@ public class ExifInterface {
|
|||||||
savePngAttributes(bufferedIn, bufferedOut);
|
savePngAttributes(bufferedIn, bufferedOut);
|
||||||
} else if (mMimeType == IMAGE_TYPE_WEBP) {
|
} else if (mMimeType == IMAGE_TYPE_WEBP) {
|
||||||
saveWebpAttributes(bufferedIn, bufferedOut);
|
saveWebpAttributes(bufferedIn, bufferedOut);
|
||||||
} else if (mMimeType == IMAGE_TYPE_DNG || mMimeType == IMAGE_TYPE_UNKNOWN) {
|
|
||||||
ByteOrderedDataOutputStream dataOutputStream =
|
|
||||||
new ByteOrderedDataOutputStream(bufferedOut, ByteOrder.BIG_ENDIAN);
|
|
||||||
writeExifSegment(dataOutputStream);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -5262,8 +5265,7 @@ public class ExifInterface {
|
|||||||
|
|
||||||
private boolean isSupportedFormatForSavingAttributes() {
|
private boolean isSupportedFormatForSavingAttributes() {
|
||||||
if (mIsSupportedFile && (mMimeType == IMAGE_TYPE_JPEG || mMimeType == IMAGE_TYPE_PNG
|
if (mIsSupportedFile && (mMimeType == IMAGE_TYPE_JPEG || mMimeType == IMAGE_TYPE_PNG
|
||||||
|| mMimeType == IMAGE_TYPE_WEBP || mMimeType == IMAGE_TYPE_DNG
|
|| mMimeType == IMAGE_TYPE_WEBP)) {
|
||||||
|| mMimeType == IMAGE_TYPE_UNKNOWN)) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user