You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
486 B
29 lines
486 B
|
3 years ago
|
import {
|
||
|
|
TEMP_PATH
|
||
|
|
} from '../constants'
|
||
|
|
|
||
|
|
import {
|
||
|
|
invoke
|
||
|
|
} from '../../bridge'
|
||
|
|
|
||
|
|
export function compressImage ({
|
||
|
|
src,
|
||
|
|
quality
|
||
|
|
}, callbackId) {
|
||
|
|
var dst = TEMP_PATH + '/compressed/' + Date.now() + (src.match(/\.\S+$/) || [''])[0]
|
||
|
|
plus.zip.compressImage({
|
||
|
|
src,
|
||
|
|
dst,
|
||
|
|
quality
|
||
|
|
}, () => {
|
||
|
|
invoke(callbackId, {
|
||
|
|
errMsg: 'compressImage:ok',
|
||
|
|
tempFilePath: dst
|
||
|
|
})
|
||
|
|
}, () => {
|
||
|
|
invoke(callbackId, {
|
||
|
|
errMsg: 'compressImage:fail'
|
||
|
|
})
|
||
|
|
})
|
||
|
|
}
|