更新 'SrcJuMethod.js'

Ju
src48597962 2 years ago
parent 5a35c6c2bb
commit ccabc82732
  1. 20
      SrcJuMethod.js

@ -92,6 +92,10 @@ function banner(start, arr, data, cfg){
//图片压缩 //图片压缩
function imageCompress(imgurl,fileid) { function imageCompress(imgurl,fileid) {
function compress(path, inSampleSize, topath) { function compress(path, inSampleSize, topath) {
let tmpfile = "hiker://files/_cache/1.txt";
if (!fileExist(tmpfile)) {
writeFile(tmpfile, '');
}
const Bitmap = android.graphics.Bitmap; const Bitmap = android.graphics.Bitmap;
const BitmapFactory = android.graphics.BitmapFactory; const BitmapFactory = android.graphics.BitmapFactory;
const FileOutputStream = java.io.FileOutputStream; const FileOutputStream = java.io.FileOutputStream;
@ -109,10 +113,6 @@ function imageCompress(imgurl,fileid) {
bitmap = BitmapFactory.decodeFile(path, options); bitmap = BitmapFactory.decodeFile(path, options);
topath = topath || path; topath = topath || path;
} }
let tmpfile = "hiker://files/_cache/1.txt";
if (!fileExist(tmpfile)) {
writeFile(tmpfile, '');
}
let os = new FileOutputStream(topath); let os = new FileOutputStream(topath);
let s = false; let s = false;
try { try {
@ -163,12 +163,12 @@ function imageCompress(imgurl,fileid) {
log(size); log(size);
if(size>1080){ if(size>1080){
log(parseInt(size/1080)); log(parseInt(size/1080));
let newpath = "/storage/emulated/0/Android/data/com.example.hikerview/files/Documents/_cache/"+(fileid||"")+"_"+getName(imgurl); //let newpath = "/storage/emulated/0/Android/data/com.example.hikerview/files/Documents/_cache/"+(fileid||"")+"_"+getName(imgurl);
log(newpath); let newpath = "/storage/emulated/0/Android/data/com.example.hikerview/files/Documents/_cache/1.jpg";
let r = compress(f, 3, newpath); compress(f, 8, newpath);
if(r){ //if(r){
return "file://" + newpath; // return "file://" + newpath;
} //}
} }
return imgurl; return imgurl;
} }

Loading…
Cancel
Save