How to use the icojs.isICO function in icojs

To help you get started, we’ve selected a few icojs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kura52 / sushi-browser / src / captureFaviconEvent.js View on Github external
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')}`)
              }
github sidneys / pb-for-desktop / app / scripts / renderer-process / pushbullet / push.js View on Github external
.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
github beakerbrowser / beaker / app / bg / browser.js View on Github external
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
  }
}

icojs

parse ico file

MIT
Latest version published 3 months ago

Package Health Score

72 / 100
Full package analysis

Popular icojs functions