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

Loading…
Cancel
Save