I am creating a telegram bot with the library "node-telegram-bot-api". I need to take users' images only in PNG format. As I understand it, Telegram converts images and creates JPEG, so I use both.downloadFile() to take PNG as a file and save it as PNG. However, it saves the users' image as JPEG. Code:
bot.on('document', message => {
if(message.document.mime_type !== 'image/png')
return bot.sendMessage(msg.chat.id, `It is not png.`);
let fileID = message.document.thumb.file_id;
bot.downloadFile(fileID, path)
.then(path => console.log(`Image saved: ${path}`))
.catch(error => console.log(error));
});