How to use terminal-image - 9 common examples

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 mixn / carbon-now-cli / cli.js View on Github external
case COPY: {
				console.log(`
  Image copied to clipboard! 😌`
				);
				break;
			}
			default: {
				console.log(`
  The file can be found here: ${downloadedAs} 😌`
				);

				if (process.env.TERM_PROGRAM && process.env.TERM_PROGRAM.match('iTerm')) {
					console.log(`
  iTerm2 should display the image below. 😊

  ${await terminalImage.file(downloadedAs)}`
					);
				}
			}
		}

		updateNotifier({pkg}).notify();

		process.exit();
	} catch (error) {
		console.error(`
  ${red('Error: Sending code to https://carbon.now.sh went wrong.')}

  This is mostly due to:

  – Insensical input like \`--start 10 --end 2\`
  – Carbon being down or taking too long to respond
github sindresorhus / doge-seed-cli / cli.js View on Github external
.split(' ')
		.map(x => chalk[randomColor()](x))
		.join(' ');

	const seedBox = boxen(seed, {
		float: 'center',
		padding: 1,
		borderStyle: 'round',
		borderColor: 'yellow',
		dimBorder: true
	});

	if (isIterm) {
		termImg(dogeImage, {width: '100%'});
	} else {
		console.log(await terminalImage.file(dogeImage));
	}

	console.log(seedBox, '\n\n\n');
})();
github greghesp / assistant-relay / server / assistant.js View on Github external
(async() => {
          console.log(await terminalImage.file('./img/logo.png'))
          console.log(`Assistant Relay is now setup and running for${users.map(u => ` ${u}`)} \n`)
          console.log(`You can now visit ${global.db.get("baseUrl").value()} in a browser, or send POST requests to it`);
        })();
        if (!global.db.get("muteStartup").value()) {
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 4 months ago

Package Health Score

61 / 100
Full package analysis

Popular terminal-image functions