问题描述
我想拍摄一个在线图像,用枕头对其进行修改,并根据要求使用Django返回修改后的文件。我将图像上传到github上,并使用请求库获取该文件。然后我使用枕头在其上添加了一些文本并返回了该文件。 我尝试过了
import requests
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
from io import BytesIO
def send(request):
url='https://github.com/AJITH-klepsydra/images/blob/master/aa.jpg?raw=true'
image=requests.get(url).content
img = Image.open(BytesIO(image))
font = ImageFont.truetype("arial.ttf",15)
draw = ImageDraw.Draw(img)
draw.text((300,200),"Hello World !",(255,255,255),font=font)
return HttpResponse(img,content_type="image/png")
但是执行时,我得到了黑色图像。没有任何内容
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)