Fix for issue #141: EXIF data stripped from captured photos in android

In order to fix this issue I needed to read the EXIF data. Save it to a temporary object then after the bitmap is compressed I open the file and write the saved EXIF data.

Supports the following EXIF fields if they are set in your image:

APERTURE
DATETIME
EXPOSURE_TIME
FLASH
FOCAL_LENGTH
GPS_ALTITUDE
GPS_ALTITUDE_REF
GPS_DATESTAMP
GPS_LATITUDE
GPS_LATITUDE_REF
GPS_LONGITUDE
GPS_LONGITUDE_REF
GPS_PROCESSING_METHOD
GPS_TIMESTAMP
ISO
MAKE
MODEL
ORIENTATION
WHITE_BALANCE
This commit is contained in:
macdonst
2011-08-23 01:38:00 +08:00
committed by brianleroux
parent 2e9cbdf38d
commit 0297807bd0
5 changed files with 1634 additions and 1458 deletions
+18 -2
View File
@@ -25,6 +25,7 @@ import android.provider.MediaStore;
import android.util.Log;
import android.webkit.MimeTypeMap;
import com.phonegap.api.PhonegapActivity;
import com.phonegap.api.Plugin;
import com.phonegap.api.PluginResult;
import com.phonegap.file.EncodingException;
@@ -39,7 +40,8 @@ import com.phonegap.file.TypeMismatchException;
*/
public class FileUtils extends Plugin {
private static final String LOG_TAG = "FileUtils";
private static final String _DATA = "_data"; // The column name where the file path is stored
public static int NOT_FOUND_ERR = 1;
public static int SECURITY_ERR = 2;
public static int ABORT_ERR = 3;
@@ -988,5 +990,19 @@ public class FileUtils extends Plugin {
return new FileInputStream(path);
}
}
/**
* Queries the media store to find out what the file path is for the Uri we supply
*
* @param contentUri the Uri of the audio/image/video
* @param ctx the current applicaiton context
* @return the full path to the file
*/
protected static String getRealPathFromURI(Uri contentUri, PhonegapActivity ctx) {
String[] proj = { _DATA };
Cursor cursor = ctx.managedQuery(contentUri, proj, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(_DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
}