Try to use realpath filename instead of default modified.jpg

This commit is contained in:
Nelson Antunes 2015-05-28 11:29:21 +01:00
parent a030c52f7f
commit dbe3e3d2ca
No known key found for this signature in database
GPG Key ID: DC47AEA772F67FBE

View File

@ -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 {