PIL 图片处理库学习


官方文档 :http://pillow.readthedocs.io/en/4.3.x/handbook/tutorial.html#using-the-image-class

#第 0000 题: 将你的 QQ 头像(或者微博头像)右上角加上红色的数字,类似于微信未读信息数量那种提示效果。 类似于图中效果
#img_url  http://diy.qqjay.com/u/files/2012/0208/72e960b5ffe59310e2bc59cf8cf9162f.jpg
#数字图片 http://pic.58pic.com/58pic/16/19/44/98a58PICjU4_1024.jpg

#import PIL
# PIL is not setuptools compatible,pillow fork from pil
# pip install pillow 


from PIL import Image
import requests
from io import BytesIO
# the way to create images instance
r = requests.get('http://pic.58pic.com/58pic/16/19/44/98a58PICjU4_1024.jpg')
numImage = Image.open(BytesIO(r.content))   #Image.open(StringIO.StringIO(buffer))

r = requests.get('http://diy.qqjay.com/u/files/2012/0208/72e960b5ffe59310e2bc59cf8cf9162f.jpg')
headImage = Image.open(BytesIO(r.content))
#rint (numImage.format,numImage.size,numImage.mode)
#rint (headImage.format,headImage.size,headImage.mode)

#create cornlable
size = (64,64)
region = numImage.resize(size)
#paste image
box = (0,0,64,64)
headImage.paste(region,box)
headImage.save('./out.jpeg')


Pingbacks已打开。

引用地址

评论
  1. JackGal JackGal 发布于 2021年3月9日 02:33 #

    <a href="https://ondansetronzofran.com/">zofran 4 mg tablet price</a> <a href="https://ivermectinpharmacy.com/">stromectol 3 mg</a> <a href="https://packcialis.com/">cialis no prescription canada</a> <a href="https://tbbstore.com/">buy keflex</a>

  2. TheronRah TheronRah 发布于 2021年3月9日 02:46 #

    india pharmacy mail order <a href=" https://genericwdp.com/# ">buy medication without an rx</a>
    buy prescription drugs: https://genericwdp.com/ buy prescription drugs
    <a href=https://genericwdp.com/#>india pharmacy mail order</a> buying prescription drugs from canada

发表评论