Answer the question
In order to leave comments, you need to log in
How to overlay one image on another in a telegram bot?
It is necessary that the bot processes the photo sent by the user and overlays a png file from the disk on it
def on_message(update, context):
chat = update.effective_chat
file = bot.get_file(update.message.photo[-1].file_id)
vesna = Image.open('C://Users//79516//Documents//vesna.png')
photo = Image.open(file.file_path)
#photo.paste(vesna)
#photo.save('C:Users//79516//Documents//photovesna.png', 'rb')
bot.send_photo(chat_id=chat.id, photo= open('C://Users//79516//Documents//photovesna.png', 'rb'))
vesna.close()
photo.close()
context.bot.send_message(chat_id=chat.id, text="hi")
updater = Updater(token, use_context=True)
dispatcher = updater.dispatcher
dispatcher.add_handler(CommandHandler("start", on_start))
dispatcher.add_handler(MessageHandler(Filters.photo, on_message))
updater.start_polling()
updater.idle()
FileNotFoundError: [Errno 2] No such file or directory: 'photos/file_1.jpg'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question