Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 '';
}
}
async function previewImage(imageData) {
const imageAsJimp = await arrayToJimp(imageData);
const pngBuffer = await imageAsJimp.getBufferAsync(jimp.MIME_PNG);
console.log(await terminalImage.buffer(pngBuffer));
}
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)
}
}