How to use the terminal-image.buffer function in terminal-image

To help you get started, we’ve selected a few terminal-image 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 rnegron / noticias-pr-cli / cli.js View on Github external
async function retrieveArticleImage(article) {
  // Verifies that the article parsed via Mercury has a lead image, and tries to fetch it
  const imageLoadingSpinner = ora('Descargando y preparando imágen...');
  try {
    logger('Working on image: %s', article.lead_image_url);

    imageLoadingSpinner.start();

    // Fetch the image using the "got" package
    const response = await got(article.lead_image_url).buffer();

    // Prepare the image for displaying it in the terminal
    const articleImage = await terminalImage.buffer(response);
    imageLoadingSpinner.succeed();

    return articleImage;
  } catch (err) {
    imageLoadingSpinner.warn('No se pudo desplegar la imágen! ' + err.message);
    return '';
  }
}
github tensorflow / tfjs-examples / fashion-mnist-vae / data.js View on Github external
async function previewImage(imageData) {
  const imageAsJimp = await arrayToJimp(imageData);
  const pngBuffer = await imageAsJimp.getBufferAsync(jimp.MIME_PNG);
  console.log(await terminalImage.buffer(pngBuffer));
}
github CODAIT / magicat / app.js View on Github external
const showPreview = async (objName, modelJSON, isDirScan = false) => {
  if (objName === true) {
    console.log(await terminalImage.buffer(Buffer.from(modelJSON.data)))
  } else if (objName && objName !== true && modelJSON.foundObjects.indexOf(objName) == -1 && !isDirScan) {
    console.log(`\n'${ objName.substr(0, 1).toUpperCase() + objName.substr(1) }' not found. ` + 
      `After the --show flag, provide an object name from the list above or 'colormap' to view the highlighted object colormap.`)
  } else if (objName && objName !== true && modelJSON.foundObjects.indexOf(objName) == -1 && isDirScan) {
    console.log(objName.substr(0, 1).toUpperCase() + objName.substr(1) + ' not found in this image.')
  }
  else {
    console.log(await terminalImage.buffer(Buffer.from(await cropObject(argv.show, modelJSON), 'base64')))
  }

  if (modelJSON.foundObjects.indexOf(objName) !== -1) {
    console.log(modelJSON.fileName)
  }
}

terminal-image

Display images in the terminal

MIT
Latest version published 3 years ago

Package Health Score

47 / 100
Full package analysis

Popular terminal-image functions