You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2015/10/16 12:52:01 UTC

cordova-plugin-camera git commit: Try to use realpath filename instead of default modified.jpg

Repository: cordova-plugin-camera
Updated Branches:
  refs/heads/master a030c52f7 -> dbe3e3d2c


Try to use realpath filename instead of default modified.jpg


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/commit/dbe3e3d2
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/dbe3e3d2
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/dbe3e3d2

Branch: refs/heads/master
Commit: dbe3e3d2ca26943feafaaf16413a0543ef4d8709
Parents: a030c52
Author: Nelson Antunes <ne...@gmail.com>
Authored: Thu May 28 11:29:21 2015 +0100
Committer: Nelson Antunes <ne...@gmail.com>
Committed: Thu Oct 15 01:21:05 2015 +0100

----------------------------------------------------------------------
 src/android/CameraLauncher.java | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/dbe3e3d2/src/android/CameraLauncher.java
----------------------------------------------------------------------
diff --git a/src/android/CameraLauncher.java b/src/android/CameraLauncher.java
index 9723a6d..d7e9be0 100644
--- a/src/android/CameraLauncher.java
+++ b/src/android/CameraLauncher.java
@@ -508,9 +508,15 @@ private void refreshGallery(Uri contentUri)
 
 
 private String ouputModifiedBitmap(Bitmap bitmap, Uri uri) throws IOException {
-        // Create an ExifHelper to save the exif data that is lost during compression
-        String modifiedPath = getTempDirectoryPath() + "/modified." +
-                (this.encodingType == JPEG ? "jpg" : "png");
+        // Some content: URIs do not map to file paths (e.g. picasa).
+        String realPath = FileHelper.getRealPath(uri, this.cordova);
+
+        // Get filename from uri
+        String fileName = realPath != null ?
+            realPath.substring(realPath.lastIndexOf('/') + 1) : 
+            "modified." + (this.encodingType == JPEG ? "jpg" : "png");
+
+        String modifiedPath = getTempDirectoryPath() + "/" + fileName;
 
         OutputStream os = new FileOutputStream(modifiedPath);
         CompressFormat compressFormat = this.encodingType == JPEG ?
@@ -520,8 +526,7 @@ private String ouputModifiedBitmap(Bitmap bitmap, Uri uri) throws IOException {
         bitmap.compress(compressFormat, this.mQuality, os);
         os.close();
 
-        // Some content: URIs do not map to file paths (e.g. picasa).
-        String realPath = FileHelper.getRealPath(uri, this.cordova);
+        // Create an ExifHelper to save the exif data that is lost during compression
         ExifHelper exif = new ExifHelper();
         if (realPath != null && this.encodingType == JPEG) {
             try {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org