Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
image = image.resize(20,Jimp.AUTO,Jimp.RESIZE_BICUBIC)
}
else{
image = image.resize(Jimp.AUTO,20,Jimp.RESIZE_BICUBIC)
}
image.getBase64(Jimp.AUTO, function (err, src) {
resolve(src)
})
// .toBuffer().then(data=>{
// resolve(`data:image/png;base64,${data.toString('base64')}`)
// })
}
})
}
else if(img.type.endsWith('icon') && ico.isICO(img)){
console.log(148,Date.now())
try{
ico.parse(img).then(function (images) {
console.log(149,Date.now())
const icoImage = images[0]
const imgBuffer = Buffer.from(icoImage.buffer)
console.log(151,Date.now())
Jimp.read(imgBuffer, function (err, image) {
if (err || !image) {
console.log("ERROR Failed to save file", err);
resolve(blob)
}
if(Math.max(image.bitmap.width,image.bitmap.height) <= 20){
console.log(146,Date.now())
resolve(`data:image/png;base64,${imgBuffer.toString('base64')}`)
}
.then((result) => {
const imageFilepathDownloaded = result.filename
const imageBuffer = result.image
const imageType = fileType(imageBuffer)
const isIco = icojs.isICO(imageBuffer)
const isPng = imageType.mime === 'image/png'
const isJpeg = imageType.mime === 'image/jpg' || imageType.mime === 'image/jpeg'
// From .PNG
if (isPng || isJpeg) {
resizeWriteImage(imageBuffer, imageFilepathDownloaded, notificationIconWidth, (error, imageFilepathConverted) => {
if (error) { return }
notificationOptions.icon = imageFilepathConverted
showNotification(notificationOptions, decoratedPush)
})
return
}
// From .ICO
properties: ['openFile']
})
if (!favicon) return
let faviconBuffer = await jetpack.readAsync(favicon[0], 'buffer')
let extension = path.extname(favicon[0])
if (extension === '.png') {
return toIco(faviconBuffer, {resize: true})
}
if (extension === '.jpg') {
let imageToPng = nativeImage.createFromBuffer(faviconBuffer).toPNG()
return toIco(imageToPng, {resize: true})
}
if (extension === '.ico' && ICO.isICO(faviconBuffer)) {
return faviconBuffer
}
}