使用Python itchat个人微信账号头像拼接
2017-10-20 09:32
1041 查看
直接上代码
注:文件夹名字需要自己创建
需要安装:1.pip install itchat 2.pip install pillow
注:文件夹名字需要自己创建
需要安装:1.pip install itchat 2.pip install pillow
import itchat import math import PIL.Image as Image import os itchat.auto_login(hotReload=True) friends = itchat.get_friends(update=True)[0:] user = friends[0]["UserName"] num = 0 for i in friends: img = itchat.get_head_img(userName=i["UserName"]) fileImage = open('文件夹'+"/"+str(num)+".jpg", 'wb') fileImage.write(img) fileImage.close() num += 1 ls = os.listdir('文件夹') each_size = int(math.sqrt(float(640 * 640) / len(ls))) lines = int(640 / each_size) image = Image.new('RGB', (640, 640)) x = 0 y = 0 for i in range(0, len(ls) + 1): try: img = Image.open("文件夹"+"/" + str(i) + ".jpg") except IOError: print("Error") else: img = img.resize((each_size, each_size), Image.ANTIALIAS) image.paste(img, (x * each_size, y * each_size)) x += 1 if x == lines: x = 0 y += 1 image.save("文件夹"+"/" + "all.jpg") itchat.send_image("文件夹"+"/" + "all.jpg", 'filehelper')
相关文章推荐
- Python itchat个人微信账号接口定时发送群消息
- Python之itchat生成微信头像拼接问题
- 使用python抓取微信好友个性签名并形成词云(itchat;wordcloud)
- itchat+pillow实现微信好友头像爬取和拼接
- 使用Python微信库itchat获得好友和群组已撤回的消息
- 用python itchat包 爬取微信好友头像形成矩形头像集
- 在python中使用itchat发送微信消息
- 在python中使用itchat发送微信消息
- python使用itchat发送微信消息提醒
- 有了 itchat, python 调用微信个人号从未如此简单(新增 py3 支持)
- python实现微信接口(itchat)
- python-itchat微信消息群发、自动回复
- Python微信库: itchat
- python实现微信接口(itchat)
- python微信库:itchat
- 利用python微信库itchat实现微信自动回复功能
- python itchat实现微信好友头像拼接图的示例代码
- python实现微信接口(itchat)详细介绍
- python微信模块 itchat
- Python微信好友信息意义及取值分析(基于itchat)