创建类似于tweets的图像
tweetmagick的Python项目详细描述
生成具有类似tweet的外观的图像
安装
pip3 install tweetmagick
示例
显示图像并在不保存的情况下退出,方法如下:
fromtweetmagickimportTweetGeneratorname="harold"longname="stockmaster"avatar="harold.jpg"text="feeling pompous today, might delete later"withTweetGenerator(name,longname,avatar,text)astg:tg.tweetgen(debug=True)
tweetgen方法返回带有png二进制blob的bytesio对象。 下面是将图像保存到文件中的代码:
fromshutilimportcopyfileobjwithTweetGenerator(name,longname,avatar,text,theme="light")astg:withopen("haroldtweets.png","wb")astweet:copyfileobj(tg.tweetgen(),tweet)
结果:
使用dark主题选项:
待办事项
实现一些在tweets中嵌入图像的简化方法。
还有一些回复/引用图像的方法