《好玩的python》学习记录贴1

安装好python

pip install ipython
pip install pillow
安装三方库

加载图片
from PIL import Image
hhh = Image.open(“ccc.jpg”)
hhh.show()

在这里百度了一下import和from …import 的区别,大致上是e.g.
import A
from A import B (B of A))

使用滤镜
from PIL import ImageFilter
hhh.filter(ImageFilter.CONTOUR).show()//轮廓
《好玩的python》学习记录贴

hhh.filter(ImageFilter.EMBOSS).show()//浮雕
hhh.filter(ImageFilter.BLUR).show()//模糊
hhh.filter(ImageFilter.EDGE-ENHANCE).show()//边缘增强
hhh.filter(ImageFilter.DETALL).show()//细节
hhh.filter(ImageFilter.SMOOTH).show()//平滑
hhh.filter(ImageFilter.SHARPEN).show()//锐化

剪切图片和粘贴图片
rect = 22,69,1000,1000//x,y,width,height。x,y是左上角点
eg = hhh.crop(rect)
《好玩的python》学习记录贴

egh=eg.filter(ImageFilter.GaussianBlur(4))//高斯模糊,半径为4
hhh.paste(egh,(22,69))
hhh.show()

相关文章: