1
I am trying to burn an image to disk and after that generate a Thumb of the images that was saved.
To do this I saved normal the image in Base64 that was sent and in the callback of Fs.writeFile I call the function to generate the Thumb.
I’m trying to generate Thumb using the package imagemagick
const im = require('imagemagick');
const fs = require('fs');
const imagemCapa = objetoFolder + "\\" + comando.imagemCapa;
const imagemCapaThumb = objetoFolder + "\\capa_thumb.jpg";
//Grava no disco
fs.writeFile(imagemCapa, comando.imagemCapaBase64, 'base64', (err) => {
if(err) console.log(err);
//Thumb
const optionsThumb = {
srcPath: imagemCapa,
dstPath: imagemCapaThumb,
width: 262
};
im.resize(optionsThumb, (err, stdout, stderr) => {
if (err) console.log(err);
console.log('Thumb gerado');
});
});
I can write the image to disk but it’s not generating Thumb.
Who can help thank you beforehand! A hug.
You shouldn’t wear
imagemCapa
in time ofcapa.jpg
? You’re always looking for the same image, not the one that was recorded. You may have folder issues too, you can explain which folder your file is in.js
and in which folder the image is saved?– Sergio
Opa @Sergio, I had put wrong. Has the variables that receive the path of the image that was saved and Thumb before, are the imageCapa and imageCapaThumb.
– Rafael Jourdan
You get an error on the Node?
– Sergio
I don’t get it, that’s the problem... it saves the image, enters the callback of the Thumb generation but doesn’t save the Thumb in fact.
– Rafael Jourdan
In the code that is in the question you have nothing to save the thumbnail. Do you know that or is that part you don’t know how to do?
– Sergio