fix(android): Support writing custom Exif tags to modified image file (#2402)
This commit is contained in:
parent
66e99d8027
commit
c748b4eccc
@ -15,6 +15,7 @@ import org.reactnative.camera.utils.RNFileUtils;
|
||||
import com.facebook.react.bridge.Arguments;
|
||||
import com.facebook.react.bridge.Promise;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.bridge.ReadableType;
|
||||
import com.facebook.react.bridge.WritableMap;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
@ -119,8 +120,20 @@ public class ResolveTakenPictureAsyncTask extends AsyncTask<Void, Void, Writable
|
||||
}
|
||||
|
||||
WritableMap exifData = null;
|
||||
ReadableMap exifExtraData = null;
|
||||
boolean writeExifToResponse = mOptions.hasKey("exif") && mOptions.getBoolean("exif");
|
||||
boolean writeExifToFile = mOptions.hasKey("writeExif") && mOptions.getBoolean("writeExif");
|
||||
boolean writeExifToFile = false;
|
||||
if (mOptions.hasKey("writeExif")) {
|
||||
switch (mOptions.getType("writeExif")) {
|
||||
case Boolean:
|
||||
writeExifToFile = mOptions.getBoolean("writeExif");
|
||||
break;
|
||||
case Map:
|
||||
exifExtraData = mOptions.getMap("writeExif");
|
||||
writeExifToFile = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Read Exif data if needed
|
||||
if (writeExifToResponse || writeExifToFile) {
|
||||
@ -136,6 +149,9 @@ public class ResolveTakenPictureAsyncTask extends AsyncTask<Void, Void, Writable
|
||||
if (fixOrientation) {
|
||||
fileExifData.putInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
|
||||
}
|
||||
if (exifExtraData != null) {
|
||||
fileExifData.merge(exifExtraData);
|
||||
}
|
||||
}
|
||||
|
||||
// Write Exif data to the response if requested
|
||||
|
||||
@ -29,7 +29,7 @@ interface TakePictureOptions {
|
||||
/** Android only */
|
||||
skipProcessing?: boolean;
|
||||
fixOrientation?: boolean;
|
||||
writeExif?: boolean;
|
||||
writeExif?: boolean | { [name: string]: any };
|
||||
|
||||
/** iOS only */
|
||||
forceUpOrientation?: boolean;
|
||||
|
||||
@ -99,7 +99,7 @@ type PictureOptions = {
|
||||
base64?: boolean,
|
||||
mirrorImage?: boolean,
|
||||
exif?: boolean,
|
||||
writeExif?: boolean,
|
||||
writeExif?: boolean | { [name: string]: any },
|
||||
width?: number,
|
||||
fixOrientation?: boolean,
|
||||
forceUpOrientation?: boolean,
|
||||
|
||||
2
types/index.d.ts
vendored
2
types/index.d.ts
vendored
@ -353,7 +353,7 @@ interface TakePictureOptions {
|
||||
/** Android only */
|
||||
skipProcessing?: boolean;
|
||||
fixOrientation?: boolean;
|
||||
writeExif?: boolean;
|
||||
writeExif?: boolean | { [name: string]: any };
|
||||
|
||||
/** iOS only */
|
||||
forceUpOrientation?: boolean;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user