How to use the image-size/lib/types/png.calculate function in image-size

To help you get started, we’ve selected a few image-size 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 brave / ethereum-remote-client / test / screens / new-ui.js View on Github external
async function generateGif(){
  // calculate screenshot size
  const screenshot = await driver.takeScreenshot()
  const pngBuffer = Buffer.from(screenshot, 'base64')
  const size = sizeOfPng.calculate(pngBuffer)

  // read only the english pngs into gif
  const encoder = new GIFEncoder(size.width, size.height)
  const stream = pngFileStream('./test-artifacts/screens/* (en).png')
    .pipe(encoder.createWriteStream({ repeat: 0, delay: 1000, quality: 10 }))
    .pipe(fs.createWriteStream('./test-artifacts/screens/walkthrough (en).gif'))

  // wait for end
  await pify(endOfStream)(stream)
}

image-size

get dimensions of any image file

MIT
Latest version published 5 hours ago

Package Health Score

88 / 100
Full package analysis