python - 使用 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>
非常感谢您!
解决方案
推荐阅读
- amazon-web-services - 轮询 dynamodb 以获取值更改
- java - 热腾腾的 java --- 使用 bash 中的 java 处理标准输入时的一些奇怪行为
- python - 当您单击不同的按钮时,两个条目打印相同的内容
- c++ - 为什么我的单链表中的迭代器类在 C++ 中给我一个分段错误?
- c - 将字符串变量传递给函数时出现分段错误,但传递字符串常量(如“hello”)时不会出现分段错误
- c# - 找不到合适的方法来覆盖 onmodelCreating .net core 3.0
- javascript - 如何在网页中多次加载包含 document.write 的 Javascript?
- java - Java - 文件读取和分隔符所需的帮助
- python - 使用克里金法或最近邻法进行空间插值?
- python - 如何为时间序列的 RNN 的双向层定义 input_shape