利用Image类将一张图片分割成9张,发朋友圈利器,打包成EXE后,长期使用。
效果大致是:

库:pillow
源码:
# pengyouquanPicture.py
# 朋友圈九宫格图片制作
from PIL import Image
import sys
# 先将input image 填充为正方形
def fill_image(image):
width, height = image.size
#选取原图片长、宽中较大值作为新图片的九宫格半径
new_image_length = width if width > height else height
#生产新图片【白底】
new_image = Image.new(image.mode,(new_image_length, new_image_length), color='white')
#将原图粘贴在新图上,位置为居中
if width > height:
new_image.paste(image,(0, int((new_image_length-heigth) / 2)))
else:
new_image.paste(

使用Python的Pillow库,将图片切割为9张,方便分享到朋友圈。通过PyInstaller打包成EXE,只需将图片命名为1.jpg并放置于EXE同目录下,执行即可完成分割。
最低0.47元/天 解锁文章
3287

被折叠的 条评论
为什么被折叠?



