Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion src/android/CameraLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,30 @@ private void processResultFromGallery(int destType, Intent intent) {

// If sending base64 image back
if (destType == DATA_URL) {
this.processPicture(bitmap, this.encodingType);
// To allow keeping the Exif data, we need to save the image to allow ExifInterface add the data
// After that, we load the image and send it as base64
try {
String modifiedPath = this.outputModifiedBitmap(bitmap, uri, mimeTypeOfGalleryFile);
InputStream fileStream = FileHelper.getInputStreamFromUriString(modifiedPath, cordova);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();

int nRead;
byte[] data = new byte[512];

while ((nRead = fileStream.read(data, 0, data.length)) != -1) {
buffer.write(data, 0, nRead);
}

buffer.flush();
byte[] file = buffer.toByteArray();

byte[] output = Base64.encode(file, Base64.NO_WRAP);
String js_out = new String(output);
this.callbackContext.success(js_out);
} catch (IOException e) {
e.printStackTrace();
this.failPicture("Error retrieving image: "+e.getLocalizedMessage());
}
}

// If sending filename back
Expand Down