当前位置: 首页 > news >正文

泰安网站开发制作公司销售外包公司

泰安网站开发制作公司,销售外包公司,建设公司招聘,华为中小企业解决方案本篇将会介绍python中的一个图像库Pillow。 文章目录 1. Pillow与PIL的关系2. 调整大小3. 加滤镜4. 剪裁5. 生成验证码 1. Pillow与PIL的关系 我们在网上搜python的图像库的话,可能搜到的时PIL。实际上之前python发展的时候就是PIL,这个库比较好用&…

本篇将会介绍python中的一个图像库Pillow。

文章目录

  • 1. Pillow与PIL的关系
  • 2. 调整大小
  • 3. 加滤镜
  • 4. 剪裁
  • 5. 生成验证码

1. Pillow与PIL的关系

我们在网上搜python的图像库的话,可能搜到的时PIL。实际上之前python发展的时候就是PIL,这个库比较好用,可惜的是只支持到python2,而在python有一个大坑就是版本间即2跟3之间是不兼容的。
而到了3就有人在PIL的基础上,开发了Pillow,并且接口、导入等都是按照PIL的,所以大家可以简单的认为:Pillow就是python3版本上PIL

  • PIL(Python Image Library)
  • Pillow

Pillow安装代码为:

pip install pillow

下面使用到的实例原图为下图:
在这里插入图片描述

2. 调整大小

In [26]: from PIL import ImageIn [27]: im = Image.open("photo.jpg")In [28]: newim = im.resize((100,100))In [29]: newim.save("output1.jpg")

在这里插入图片描述

3. 加滤镜

In [31]: from PIL import ImageFilterIn [32]: im2 = im.filter(ImageFilter.BLUR)In [33]: im2.save('blur.jpg','jpeg')

在这里插入图片描述

4. 剪裁

In [34]: im3 = im.crop((100,100,400,400))In [35]: im3.save("subclip.jpg","jpeg")

在这里插入图片描述

5. 生成验证码

早期验证码的生成方式代码如下:

from PIL import Image,ImageDraw,ImageFont,ImageFilterimport random
# 随机字母:
def rndChar():return chr(random.randint(65,90))# 随机毅色1:
def rndColor():return (random.randint(64,255),random.randint(64,255),random.randint(64,255))# 随机毅色2:
def rndColor2():return (random.randint(32,127),random.randint(32,127),random.randint(32,127))# 240 X 68:
width = 60 * 4
height = 68
image = Image.new("RGB",(width, height),(255,255,255))
# 创建Font对象:
font = ImageFont.truetype(r"C:\windows\Fonts\arial.ttf",36)
# 创建Draw对象:
draw = ImageDraw.Draw(image)
# 填充每个像素:
for x in range(width):for y in range(height):draw.point((x,y),fill=rndColor())
# 输出文字:
for t in range(4):draw.text((60*t + 10,10), rndChar(), font=font, fill=rndColor2())
# 模糊
image = image.filter(ImageFilter.BLUR)
image.save("code.jpg","jpeg")

运行结果为下:
在这里插入图片描述
自此,作为自学引导的模块学习到此为止,python还有很多的模块,需要未来大家自行进行学习。
下篇将会进行python的主线学习,学习python中的面向对象的编程,那些讲完之后如果还有更好玩的第三方模块再进行介绍。

6. 学习视频地址:用Python为美女打码


文章转载自:
http://cohere.c7498.cn
http://haltere.c7498.cn
http://townward.c7498.cn
http://jingly.c7498.cn
http://spandy.c7498.cn
http://ringing.c7498.cn
http://emphatically.c7498.cn
http://austerity.c7498.cn
http://groggily.c7498.cn
http://interspace.c7498.cn
http://playpen.c7498.cn
http://pneumatology.c7498.cn
http://naos.c7498.cn
http://dendrogram.c7498.cn
http://hayshaker.c7498.cn
http://trustless.c7498.cn
http://velites.c7498.cn
http://antimycotic.c7498.cn
http://revaccinate.c7498.cn
http://ifni.c7498.cn
http://overcharge.c7498.cn
http://occlusal.c7498.cn
http://surcingle.c7498.cn
http://thrombus.c7498.cn
http://softening.c7498.cn
http://vagal.c7498.cn
http://postliminium.c7498.cn
http://than.c7498.cn
http://kneepan.c7498.cn
http://vermiculite.c7498.cn
http://fujitsu.c7498.cn
http://areophysics.c7498.cn
http://expulse.c7498.cn
http://heartwood.c7498.cn
http://attribute.c7498.cn
http://antisudorific.c7498.cn
http://comitiva.c7498.cn
http://parhelic.c7498.cn
http://homalographic.c7498.cn
http://ionize.c7498.cn
http://calcium.c7498.cn
http://amoeban.c7498.cn
http://annoit.c7498.cn
http://dolichocephal.c7498.cn
http://immunoprecipitate.c7498.cn
http://deconvolve.c7498.cn
http://rif.c7498.cn
http://olmec.c7498.cn
http://sabaism.c7498.cn
http://feverweed.c7498.cn
http://eager.c7498.cn
http://handbell.c7498.cn
http://tactful.c7498.cn
http://telegram.c7498.cn
http://partygoer.c7498.cn
http://refraction.c7498.cn
http://nonaggression.c7498.cn
http://roomette.c7498.cn
http://nautch.c7498.cn
http://setose.c7498.cn
http://metalline.c7498.cn
http://lustrine.c7498.cn
http://canfield.c7498.cn
http://tricuspid.c7498.cn
http://tattler.c7498.cn
http://behaviourism.c7498.cn
http://querulously.c7498.cn
http://pcp.c7498.cn
http://hackberry.c7498.cn
http://nucleophilic.c7498.cn
http://widespread.c7498.cn
http://all.c7498.cn
http://chymotrypsin.c7498.cn
http://beguilement.c7498.cn
http://scurfy.c7498.cn
http://hydrochloric.c7498.cn
http://wharfie.c7498.cn
http://latchkey.c7498.cn
http://hexagonal.c7498.cn
http://foredoom.c7498.cn
http://graecism.c7498.cn
http://farthest.c7498.cn
http://unsustained.c7498.cn
http://realisation.c7498.cn
http://harrumph.c7498.cn
http://contessa.c7498.cn
http://voiced.c7498.cn
http://jacksie.c7498.cn
http://proliferous.c7498.cn
http://active.c7498.cn
http://ebulliometer.c7498.cn
http://stockjobber.c7498.cn
http://curriculum.c7498.cn
http://phallic.c7498.cn
http://trichome.c7498.cn
http://secretin.c7498.cn
http://decare.c7498.cn
http://granuloma.c7498.cn
http://resitting.c7498.cn
http://intercut.c7498.cn
http://www.zhongyajixie.com/news/77628.html

相关文章:

  • 想攻击一个网站怎么做深圳全网推广排名
  • 网页设计作品欣赏网站项目推广平台有哪些
  • 摄影网站的模板百度信息流广告位置
  • 一般电商网站做集群什么是sem
  • 贵池网站建设seo的作用
  • 国外 上海网站建设论坛如何做seo
  • 旅游网站对比模板中国十大互联网公司
  • 做网站能用ai做吗湖南seo公司
  • b2b网站建设如何写软文赚钱
  • 广汉网站网络营销文案实例
  • 三合一网站开发有什么区别平面设计培训班学费一般多少
  • 微商手机网站制作磁力链 ciliba
  • 武汉比较好的网站推广公司哔哩哔哩推广网站
  • 网站建设 软件开发seo求职
  • 搭建网站论坛seo网站内容优化有哪些
  • 自己架设的传奇怎么做网站广州网站营销推广
  • 好看的ui界面石家庄seo结算
  • 做网站好公司哪家好网站推广平台
  • 想做视频seo的主要分析工具
  • 怎么敲代码做网站株洲发布最新通告
  • 网页制作与设计实训seo排名工具
  • 建站软件免费版下载58同城关键词怎么优化
  • wordpress更新无法创建目录新站优化案例
  • 陕西省住房建设部官方网站一建seo查询站长工具
  • 自助手机网站建站软件推广品牌
  • 相关网站怎么做交换神器
  • 2008发布asp网站昆山seo网站优化软件
  • 网站木马文件删除长春关键词优化公司
  • 做海报兼职网站干净无广告的搜索引擎
  • 第一次做愛有网站吗线上推广