mirror of
https://github.com/apache/cordova-android.git
synced 2025-03-16 00:11:03 +08:00
[CB-2432] Don't try and write exif info for images from picasa
This commit is contained in:
parent
d3b7903af8
commit
191f31baa7
@ -419,14 +419,7 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.correctOrientation) {
|
if (this.correctOrientation) {
|
||||||
String[] cols = { MediaStore.Images.Media.ORIENTATION };
|
rotate = getImageOrientation(uri);
|
||||||
Cursor cursor = this.cordova.getActivity().getContentResolver().query(uri,
|
|
||||||
cols, null, null, null);
|
|
||||||
if (cursor != null) {
|
|
||||||
cursor.moveToPosition(0);
|
|
||||||
rotate = cursor.getInt(0);
|
|
||||||
cursor.close();
|
|
||||||
}
|
|
||||||
if (rotate != 0) {
|
if (rotate != 0) {
|
||||||
Matrix matrix = new Matrix();
|
Matrix matrix = new Matrix();
|
||||||
matrix.setRotate(rotate);
|
matrix.setRotate(rotate);
|
||||||
@ -446,23 +439,25 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
|
|||||||
try {
|
try {
|
||||||
// Create an ExifHelper to save the exif data that is lost during compression
|
// Create an ExifHelper to save the exif data that is lost during compression
|
||||||
String resizePath = DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()) + "/resize.jpg";
|
String resizePath = DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()) + "/resize.jpg";
|
||||||
|
// Some content: URIs do not map to file paths (e.g. picasa).
|
||||||
|
String realPath = FileHelper.getRealPath(uri, this.cordova);
|
||||||
ExifHelper exif = new ExifHelper();
|
ExifHelper exif = new ExifHelper();
|
||||||
|
if (realPath != null && this.encodingType == JPEG) {
|
||||||
try {
|
try {
|
||||||
if (this.encodingType == JPEG) {
|
exif.createInFile(realPath);
|
||||||
exif.createInFile(FileHelper.getRealPath(uri, this.cordova));
|
|
||||||
exif.readExifData();
|
exif.readExifData();
|
||||||
rotate = exif.getOrientation();
|
rotate = exif.getOrientation();
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
OutputStream os = new FileOutputStream(resizePath);
|
OutputStream os = new FileOutputStream(resizePath);
|
||||||
bitmap.compress(Bitmap.CompressFormat.JPEG, this.mQuality, os);
|
bitmap.compress(Bitmap.CompressFormat.JPEG, this.mQuality, os);
|
||||||
os.close();
|
os.close();
|
||||||
|
|
||||||
// Restore exif data to file
|
// Restore exif data to file
|
||||||
if (this.encodingType == JPEG) {
|
if (realPath != null && this.encodingType == JPEG) {
|
||||||
exif.createOutFile(resizePath);
|
exif.createOutFile(resizePath);
|
||||||
exif.writeExifData();
|
exif.writeExifData();
|
||||||
}
|
}
|
||||||
@ -496,6 +491,19 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getImageOrientation(Uri uri) {
|
||||||
|
String[] cols = { MediaStore.Images.Media.ORIENTATION };
|
||||||
|
Cursor cursor = cordova.getActivity().getContentResolver().query(uri,
|
||||||
|
cols, null, null, null);
|
||||||
|
int rotate = 0;
|
||||||
|
if (cursor != null) {
|
||||||
|
cursor.moveToPosition(0);
|
||||||
|
rotate = cursor.getInt(0);
|
||||||
|
cursor.close();
|
||||||
|
}
|
||||||
|
return rotate;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Figure out if the bitmap should be rotated. For instance if the picture was taken in
|
* Figure out if the bitmap should be rotated. For instance if the picture was taken in
|
||||||
* portrait mode
|
* portrait mode
|
||||||
|
Loading…
x
Reference in New Issue
Block a user