бот тг водяной знак

бот пишет ошибку

[Errno 2] No such file or directory: 'D:/Python/TeleGramWaterMurkBot/фотОчки/photos/file_12.jpg'

код

from PIL import Image, ImageEnhance
import telebot
import os
import time
import config
from telebot import types


bot = telebot.TeleBot(config.TOKEN)
images = dict()


def add_watermark_imp(image, watermark, opacity=1, wm_interval=0):
    assert opacity >= 0 and opacity <= 1
    if opacity < 1:
        if watermark.mode != 'RGBA':
            watermark = watermark.convert('RGBA')
        else:
            watermark = watermark.copy()
        alpha = watermark.split()[3]
        alpha = ImageEnhance.Brightness(alpha).enhance(opacity)
        watermark.putalpha(alpha)
    layer = Image.new('RGBA', image.size, (0,0,0,0))
    layer.paste(watermark, (0, 0))
    return Image.composite(layer,  image,  layer)

def add_watermark(image_path, watermark_path):
    img = Image.open(image_path) 
    watermark = Image.open(watermark_path)
    watermark = watermark.resize((100,100), Image.ANTIALIAS)
    result = add_watermark_imp(img,watermark)
    new_path = image_path + '_' + '.png'
    result.save(new_path)
    return new_path

@bot.message_handler(commands=['start'])
def start(message):
    markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
    btn1 = types.KeyboardButton("Фото")
    btn2 = types.KeyboardButton("Текст")
    markup.add(btn1,btn2)
    bot.send_message(message.chat.id, text="Выбери тип водяного знака".format(message.from_user), reply_markup=markup)
    
@bot.message_handler(content_types=['text'])
def func(message):
    if(message.text == "Фото"):
        bot.send_message(message.chat.id, text="Отправь мне 1 фото и 2 фото водяной знак")
        bot.register_next_step_handler(message, handle_docs_photo)
    elif(message.text == "Текст"):
        bot.send_message(message.chat.id, text="Отправь мне фото и текст")
    
    
    elif (message.text == "Вернуться в главное меню"):
        markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
        button1 = types.KeyboardButton("Фото")
        button2 = types.KeyboardButton("Текст")
        markup.add(button1, button2)
        bot.send_message(message.chat.id, text="Вы вернулись в главное меню", reply_markup=markup)
    else:
        bot.send_message(message.chat.id, text="На такую комманду я не запрограммировал..")

@bot.message_handler(content_types=['photo'])
def handle_docs_photo(message):
    print(message.photo[:-2])
    images[str(message.chat.id)] = []
    try:
        file_info = bot.get_file(message.photo[len(message.photo)-1].file_id)
        
        downloaded_file = bot.download_file(file_info.file_path)
        
        src = 'D:/Python/TeleGramWaterMurkBot/фотОчки/' + file_info.file_path
        
        with open(src, 'wb') as new_file:
           new_file.write(downloaded_file)
           
        bot.reply_to(message,"Фото добавлено")
        images[str(message.chat.id)].append(src)
    except Exception as e:
        bot.reply_to(message,e )

    time.sleep(int(config.Time))
    print('img: ', images)
    reply_img = ''    
    if (len(images[str(message.chat.id)]) == 2):
        reply_img = add_watermark(images[str(message.chat.id)][1], images[str(message.chat.id)][0])
        images[str(message.chat.id)].append(reply_img)
        bot.send_photo(message.chat.id, open(reply_img, 'rb'))
        
        
        
        
bot.polling(none_stop=True, interval=0)

Ответы (0 шт):