74 lines
2.3 KiB
Markdown
74 lines
2.3 KiB
Markdown
|
|
```
|
|||
|
|
// uni-app<70>е<EFBFBD><D0B5>÷<EFBFBD><C3B7><EFBFBD>
|
|||
|
|
uni.chooseImage({
|
|||
|
|
sizeType: ['original'],
|
|||
|
|
sourceType: ['camera'],
|
|||
|
|
success: function (res) {
|
|||
|
|
console.log(JSON.stringify(res.tempFilePaths));
|
|||
|
|
var allFiles = res.tempFilePaths;
|
|||
|
|
var tmpimg = allFiles[0];
|
|||
|
|
console.log(tmpimg)
|
|||
|
|
//#ifdef APP-PLUS
|
|||
|
|
plus.io.resolveLocalFileSystemURL(tmpimg, function(entry){
|
|||
|
|
entry.file(function(file){
|
|||
|
|
var reader = new plus.io.FileReader();
|
|||
|
|
reader.onloadend = function (e) {
|
|||
|
|
var base64=e.target.result
|
|||
|
|
console.log(base64);
|
|||
|
|
var name=tmpimg.substring(tmpimg.lastIndexOf('/') + 1);
|
|||
|
|
var img={path:tmpimg,name:name,src:base64};
|
|||
|
|
var EXIF=require('@/common/js_sdk/exif/exif.js');
|
|||
|
|
EXIF.getData(img, function(){
|
|||
|
|
console.log(EXIF.pretty(this));
|
|||
|
|
console.log('AllTags:',EXIF.getAllTags(this)) // <20>˴<EFBFBD><CBB4><EFBFBD>ӡ<EFBFBD><D3A1>Ϊѡ<CEAA><D1A1>ͼƬ<CDBC><C6AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
console.log(EXIF.getTag(this, 'Orientation'));
|
|||
|
|
var tagj=EXIF.getTag(this,'GPSLongitude');
|
|||
|
|
var tagw=EXIF.getTag(this,'GPSLatitude');
|
|||
|
|
if(tagj&&tagw) {
|
|||
|
|
var longitude=tagj[0]+tagj[1]/60+tagj[2]/60/60;
|
|||
|
|
var latitude=tagw[0]+tagw[1]/60+tagw[2]/60/60;
|
|||
|
|
var lalinfo=this.name+":"+longitude+":"+latitude+",";
|
|||
|
|
console.log(lalinfo);
|
|||
|
|
uni.openLocation({latitude:latitude,longitude:longitude});
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
};
|
|||
|
|
reader.readAsDataURL(file);
|
|||
|
|
},function(e){
|
|||
|
|
console.log("<22><>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>쳣: " + e.message );
|
|||
|
|
throw "Could not load image";
|
|||
|
|
})
|
|||
|
|
})
|
|||
|
|
//#endif
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//#ifdef H5
|
|||
|
|
<input type="file" accept="image/*" id="uploadImage" capture="camera" <EFBFBD><EFBFBD>nchange="selectFileImage(this);" />
|
|||
|
|
function selectFileImage(fileObj) {
|
|||
|
|
var file = fileObj.files['0'];
|
|||
|
|
//ͼƬ<CDBC><C6AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> added by lzk
|
|||
|
|
var Orientation = null;
|
|||
|
|
if (file) {
|
|||
|
|
console.log("<22><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>,<2C><><EFBFBD>Ժ<EFBFBD>...");
|
|||
|
|
var rFilter = /^(image\/jpeg|image\/png)$/i; // <20><><EFBFBD><EFBFBD>ͼƬ<CDBC><C6AC>ʽ
|
|||
|
|
if (!rFilter.test(file.type)) {
|
|||
|
|
//showMyTips("<22><>ѡ<EFBFBD><D1A1>jpeg<65><67>png<6E><67>ʽ<EFBFBD><CABD>ͼƬ", false);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
// var URL = URL || webkitURL;
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1>Ƭ<EFBFBD><C6AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD><D4A3>û<EFBFBD><C3BB><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>
|
|||
|
|
EXIF.getData(file, function() {
|
|||
|
|
// alert(EXIF.pretty(this));
|
|||
|
|
EXIF.getAllTags(this);
|
|||
|
|
//alert(EXIF.getTag(this, 'Orientation'));
|
|||
|
|
Orientation = EXIF.getTag(this, 'Orientation');
|
|||
|
|
//return;
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
...
|
|||
|
|
}
|
|||
|
|
//#endif
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
```
|