getExifForKey

getExifForKey
This commit is contained in:
dmcBig
2018-08-07 15:29:30 +08:00
parent d855808f39
commit c5c0df5c4f
5 changed files with 36 additions and 29 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-mediapicker-dmcbig",
"version": "2.3.0",
"version": "2.3.2",
"description": "android ios mediaPicker support selection of multiple image and video",
"cordova": {
"id": "cordova-plugin-mediapicker-dmcbig",
@@ -35,5 +35,5 @@
"bugs": {
"url": "https://github.com/DmcSDK/cordova-plugin-mediaPicker/issues"
},
"homepage": "https://github.com/DmcSDK/cordova-plugin-mediaPicker#readme"
"homepage": "https://github.com/DmcSDK"
}
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-mediapicker-dmcbig" version="2.3.0">
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-mediapicker-dmcbig" version="2.3.2">
<name>MediaPicker</name>
<js-module name="MediaPicker" src="www/MediaPicker.js">
<clobbers target="window.MediaPicker"/>
+30 -17
View File
@@ -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 {
+3 -8
View File
@@ -1,4 +1,3 @@
cordova.define("cordova-plugin-mediapicker-dmcbig.MediaPicker", function(require, exports, module) {
var exec = require('cordova/exec');
@@ -23,14 +22,10 @@ var MediaPicker = {
},
fileToBlob:function(arg0, success, error) {
exec(success, error, "MediaPicker", "fileToBlob", [arg0]);
},
getExif:function(arg0, success, error) {
exec(success, error, "MediaPicker", "getExif", [arg0]);
},
getExifForKey:function(arg0,arg1, success, error) {
exec(success, error, "MediaPicker", "getExifForKey", [arg0,arg1]);
}
};
module.exports = MediaPicker;
});
-1
View File
@@ -19,7 +19,6 @@ function getThumbnail(medias) {
//loading(); //show loading ui
MediaPicker.extractThumbnail(medias[i], function(data) {
imgs[data.index].src = 'data:image/jpeg;base64,' + data.thumbnailBase64;
imgs[data.index].setAttribute('style', 'transform:rotate(' + data.exifRotate + 'deg)');
}, function(e) { console.log(e) });
}
}