mirror of
https://github.com/DmcSDK/cordova-plugin-mediaPicker
synced 2026-05-22 00:01:31 +08:00
getExifForKey
getExifForKey
This commit is contained in:
@@ -44,7 +44,7 @@ public class MediaPicker extends CordovaPlugin {
|
||||
@Override
|
||||
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
|
||||
getPublicArgs(args);
|
||||
|
||||
|
||||
if (action.equals("getMedias")) {
|
||||
this.getMedias(args, callbackContext);
|
||||
return true;
|
||||
@@ -63,6 +63,9 @@ public class MediaPicker extends CordovaPlugin {
|
||||
}else if(action.equals("fileToBlob")){
|
||||
this.fileToBlob(args.getString(0), callbackContext);
|
||||
return true;
|
||||
}else if(action.equals("getExifForKey")){
|
||||
this.getExifForKey(args.getString(0),args.getString(1),callbackContext);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -227,23 +230,23 @@ public class MediaPicker extends CordovaPlugin {
|
||||
|
||||
public void compressImage( JSONArray args, CallbackContext callbackContext){
|
||||
this.callback=callbackContext;
|
||||
try {
|
||||
JSONObject jsonObject = args.getJSONObject(0);
|
||||
String path = jsonObject.getString("path");
|
||||
int quality=jsonObject.getInt("quality");
|
||||
if(quality<100) {
|
||||
File file = compressImage(path, quality);
|
||||
jsonObject.put("path", file.getPath());
|
||||
jsonObject.put("size", file.length());
|
||||
jsonObject.put("name", file.getName());
|
||||
callbackContext.success(jsonObject);
|
||||
}else{
|
||||
callbackContext.success(jsonObject);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
callbackContext.error("compressImage error"+e);
|
||||
e.printStackTrace();
|
||||
try {
|
||||
JSONObject jsonObject = args.getJSONObject(0);
|
||||
String path = jsonObject.getString("path");
|
||||
int quality=jsonObject.getInt("quality");
|
||||
if(quality<100) {
|
||||
File file = compressImage(path, quality);
|
||||
jsonObject.put("path", file.getPath());
|
||||
jsonObject.put("size", file.length());
|
||||
jsonObject.put("name", file.getName());
|
||||
callbackContext.success(jsonObject);
|
||||
}else{
|
||||
callbackContext.success(jsonObject);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
callbackContext.error("compressImage error"+e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public File compressImage(String path,int quality){
|
||||
@@ -314,6 +317,16 @@ public class MediaPicker extends CordovaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
public void getExifForKey(String path,String tag, CallbackContext callbackContext) {
|
||||
try {
|
||||
ExifInterface exifInterface = new ExifInterface(path);
|
||||
String object = exifInterface.getAttribute(tag);
|
||||
callbackContext.success(object);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public String fileToBase64(String path) {
|
||||
byte[] data = null;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user