Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const reader = new FileReader();
reader.addEventListener('loadend', () => {
// reader.result contains the contents of blob as a DataURL
resolve(reader.result);
});
reader.readAsDataURL(result);
},
error(err) {
console.error(err.message);
}
});
console.debug(compressor);
return;
} else if (photoType === PhotoType.Viewer) {
const compressor = new Compressor(itemValue, {
quality: 0.6,
maxWidth: 2560,
mimeType,
checkOrientation: false,
success(result) {
const reader = new FileReader();
reader.addEventListener('loadend', () => {
// reader.result contains the contents of blob as a DataURL
resolve(reader.result);
});
reader.readAsDataURL(result);
},
error(err) {
console.error(err.message);
}
imgCompress(fullName, cb) {
let data = fs.readFileSync(fullName);
let file = new File([data], path.basename(fullName), { type: this.fileTypeMap[path.extname(fullName).substr(1)] });
if (this.$root.imgWidth > 0 && this.$root.imgHight > 0) {
new compressor(file, {
quality: 0.8,
success(result) {
fs.unlinkSync(fullName)
let fr = new FileReader();
fr.onload = () => {
if (fr.readyState == 2) {
var buffer = new Buffer.from(fr.result);
fs.writeFileSync(fullName, buffer);
cb();
}
};
fr.readAsArrayBuffer(result);
},
error(err) {
console.log(err.message);
},
return new Promise((resolve, reject) => {
new Compressor(blob, Object.assign(
{},
this.opts,
{
success: (result) => {
return resolve(result)
},
error: (err) => {
return reject(err)
}
}
))
})
}