首页 > 解决方案 > 使用 python 枕头生成图像时出错

问题描述

我正在为不和谐创建一个生成图像的机器人,但我遇到了问题,它给了我一个问题,它不生成图像,我找不到可能的解决方案

图片:https ://i.stack.imgur.com/f9Raw.png

在这里我留下我的代码,看看是否有人可以帮助我解决它

import json
import requests
import discord
from discord.ext import commands
from PIL import Image, ImageDraw, ImageFont

bot = commands.Bot(command_prefix='!', description="ayuda bot") 
bot.remove_command("help") 

@bot.command()
async def item(ctx, *, Nombre):
    response = requests.get(f"https://fortnite-api.com/v2/cosmetics/br/search/all?language=es&name=" +Nombre+ "&searchLanguage=es")
    imagen = response.json()['data'][0]['images']['icon']
    url_imagen = f"{imagen}"
    nombre_local_imagen = "cosmetic.png"
    imagen = requests.get(url_imagen).content
    with open(nombre_local_imagen, 'wb') as handler:
        handler.write(imagen)
        img2 = Image.open(r"cosmetico.png") 
        img1 = Image.open(r"cosmetico.png") 
        draw = ImageDraw.Draw(img2)
        font = ImageFont.truetype("BurbankBigCondensed-Black.otf", 60)

        draw.text((75, 10), f"IKÓNIKO", font=font, fill="white")  

        img1.paste(img2,(0,0), mask = img2) 
        img1.save("cosmetico.png")
        await ctx.send(file=discord.File('cosmetico.png'))
        img1.save("cosmetico.png")
bot.run('')

看看有没有人可以给我一根电缆来解决它☺</p>

非常感谢您!

标签: python

解决方案


推荐阅读