From dbe3e3d2ca26943feafaaf16413a0543ef4d8709 Mon Sep 17 00:00:00 2001 From: Nelson Antunes Date: Thu, 28 May 2015 11:29:21 +0100 Subject: [PATCH] Try to use realpath filename instead of default modified.jpg --- src/android/CameraLauncher.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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 {