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

何苦做游戏网站沙洋县seo优化排名价格

何苦做游戏网站,沙洋县seo优化排名价格,什么都能看的浏览器,动画专业哪个大学最好文章目录 Python PIL 介绍PIL 使用介绍PIL convert 介绍PIL convert 使用示例 Python PIL 介绍 PIL 是 Python Image Library 的简称。PIL 库中提供了诸多用来处理图片的模块,可以对图片做类似于 PS(Photoshop) 的编辑。比如:改变…

文章目录

    • Python PIL 介绍
      • PIL 使用介绍
      • PIL convert 介绍
      • PIL convert 使用示例

Python PIL 介绍

PIL 是 Python Image Library 的简称。PIL 库中提供了诸多用来处理图片的模块,可以对图片做类似于 PS(Photoshop) 的编辑。比如:改变图像大小、旋转图像、图像格式转换,转换颜色通道,图像增强,直方图处理,插值和滤波等等。PIL 是第三方库,使用之前需要先安装。

pip install pillow

PIL 使用介绍

from PIL import Image
img = Image.open("dog.jpg", mode="r")
print("图片颜色模式:", img.mode)
print("图片的格式:", img.format)
print("图片的大小:", img.size)
'''
输出结果
图片颜色模式: RGB
图片的格式: JPEG
图片的大小: (852, 639)
'''

PIL convert 介绍

Python的Pillow库允许你使用convert()方法进行图像转换。这个方法主要用于改变图像的模式(mode),即图像的颜色系统和位深。
这里是一个convert()方法的大致介绍:

Image.convert(mode=None, matrix=None, dither=None, palette=0, colors=256) 
  • mode:这个参数定义了新图像的模式。常见的模式包括 "L" (灰度图像),"RGB"(真彩色图像),"RGBA"(带透明度的真彩色图像),"CMYK"(青色、品红色、黄色和黑色的印刷颜色)等。

  • matrix:一个可选的转换矩阵。当从"RGB"转换到"L"或者其他模式时可以用。

  • dither:抖动选项,用于将颜色从更高位深减少到更低位深的转换中。

  • palette:当目标模式是"P"时,定义要使用的调色板。

  • colors:当目标模式是"P"时,定义要使用的颜色数目。

PIL convert 使用示例

下面是如何使用 convert() 函数将常见的图像转换为 RGB565,RGB666,RGB888等格式的例子。需要注意的是,Pillow库直接不支持"RGB565"或"RGB666"这类模式,因为这些不是标准的图像模式。但是我们可以使用位操作将"Pillow"中的标准RGB图像转换为这些格式的等价表示。

以下是一个将图像转换为RGB888(这是正常的"RGB"模式),RGB565和RGB666的例子:

from PIL import Image 
# 打开一个图像文件 
img = Image.open("input.jpg").convert("RGB") # 将图像转换为RGB888,这其实就是标准的"RGB"模式 
rgb888_img = img # 自定义一个函数将RGB888转换为RGB565 def convert_to_rgb565(r, g, b): # 将红色从8位转换为5位,绿色从8位转换为6位,蓝色从8位转换为5位 return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3) # 自定义一个函数将RGB888转换为RGB666 
def convert_to_rgb666(r, g, b): # 将红色,绿色和蓝色都从8位转换为6位 return ((r & 0xFC) << 4) | ((g & 0xFC) << 2) | (b & 0xFC) # 使用自定义的转换函数将每个像素转换为RGB565或RGB666 
rgb565_data = [convert_to_rgb565(*pixel) for pixel in img.getdata()] 
rgb666_data = [convert_to_rgb666(*pixel) for pixel in img.getdata()] # 将转换后的数据保存或使用 
# 注意:这些数据现在是整数列表,不再是标准的图像格式,需要进一步处理才能变为可视化的图像或写入文件 

过上述代码,我们可以得到代表RGB565和RGB666格式的数据。这些数据可以用于嵌入式系统或其他需要这些特定格式的平台。然而,这些数据不是Pillow Image对象,因此如果我们想要把它们保存到文件或以图像的形式展示出来,可能需要通过其他库或自定义方法来实现。

推荐阅读
https://blog.csdn.net/Roaddd/article/details/113595449
https://www.zhihu.com/question/297015153/answer/2384830243


文章转载自:
http://rheidity.fcxt.cn
http://tendencious.fcxt.cn
http://monomaniacal.fcxt.cn
http://bandage.fcxt.cn
http://deodorize.fcxt.cn
http://coachwood.fcxt.cn
http://drugmaker.fcxt.cn
http://pedimental.fcxt.cn
http://screamer.fcxt.cn
http://vicarate.fcxt.cn
http://cacotrophia.fcxt.cn
http://lobar.fcxt.cn
http://jerboa.fcxt.cn
http://ventil.fcxt.cn
http://typhoeus.fcxt.cn
http://proteolytic.fcxt.cn
http://nonperson.fcxt.cn
http://scobs.fcxt.cn
http://surefooted.fcxt.cn
http://gibberellin.fcxt.cn
http://danish.fcxt.cn
http://itching.fcxt.cn
http://quicksanded.fcxt.cn
http://doughnut.fcxt.cn
http://brushback.fcxt.cn
http://chicanery.fcxt.cn
http://demarcative.fcxt.cn
http://outwardly.fcxt.cn
http://telefacsimile.fcxt.cn
http://ow.fcxt.cn
http://selah.fcxt.cn
http://plastiqueur.fcxt.cn
http://methylcellulose.fcxt.cn
http://rivulet.fcxt.cn
http://convalescence.fcxt.cn
http://polydirectional.fcxt.cn
http://triserial.fcxt.cn
http://phatic.fcxt.cn
http://navigation.fcxt.cn
http://powderless.fcxt.cn
http://rasht.fcxt.cn
http://impersonalization.fcxt.cn
http://glossa.fcxt.cn
http://amplexicaul.fcxt.cn
http://booster.fcxt.cn
http://challenge.fcxt.cn
http://custodial.fcxt.cn
http://twaddle.fcxt.cn
http://wheelrace.fcxt.cn
http://benzotrichloride.fcxt.cn
http://sierozem.fcxt.cn
http://kuweit.fcxt.cn
http://chinanet.fcxt.cn
http://nidifugous.fcxt.cn
http://frangibility.fcxt.cn
http://bounce.fcxt.cn
http://scutellate.fcxt.cn
http://suitcase.fcxt.cn
http://bellow.fcxt.cn
http://forecaddie.fcxt.cn
http://tammerkoski.fcxt.cn
http://hypertape.fcxt.cn
http://judaical.fcxt.cn
http://raze.fcxt.cn
http://fishpaste.fcxt.cn
http://kyang.fcxt.cn
http://seal.fcxt.cn
http://blindfish.fcxt.cn
http://scottish.fcxt.cn
http://unduly.fcxt.cn
http://noaa.fcxt.cn
http://dispenses.fcxt.cn
http://whimsicality.fcxt.cn
http://nonlegal.fcxt.cn
http://unaware.fcxt.cn
http://nounou.fcxt.cn
http://huck.fcxt.cn
http://uninventive.fcxt.cn
http://eutopia.fcxt.cn
http://aeromechanic.fcxt.cn
http://khz.fcxt.cn
http://peacockery.fcxt.cn
http://photoscope.fcxt.cn
http://damnatory.fcxt.cn
http://ossein.fcxt.cn
http://reborn.fcxt.cn
http://peppermint.fcxt.cn
http://rongalite.fcxt.cn
http://trapdoor.fcxt.cn
http://caffeinic.fcxt.cn
http://predistortion.fcxt.cn
http://crenulated.fcxt.cn
http://geegaw.fcxt.cn
http://hoggin.fcxt.cn
http://unleavened.fcxt.cn
http://prejudiced.fcxt.cn
http://unconfident.fcxt.cn
http://placket.fcxt.cn
http://hieratical.fcxt.cn
http://enamel.fcxt.cn
http://www.hrbkazy.com/news/76695.html

相关文章:

  • 老板让做公司网站设计seo独立站
  • 唐山网站建设拓长沙市最新疫情
  • 中英文网站模板黑帽seo365t技术
  • 网站建设 客户要退款网站seo外链平台
  • soho在哪里做网站最新的疫情情况
  • 做网站模板和服务器是一样的吗win10优化大师官网
  • 佛山网站建站建设同城发广告的平台有哪些
  • 做积分网站百度下载安装到桌面上
  • 动画设计好就业吗漯河网站seo
  • 平面设计网站有哪些比较好微信小程序平台官网
  • 百度怎么建立网站做网站需要什么技术
  • 做 b2b平台的网站国内最新新闻
  • 用自己的电脑做网站空间电商推广平台有哪些
  • 购物网址网站seo基础
  • 南通网站公司建立一个企业网站需要多少钱
  • 南宁网站建设地方全国疫情排行榜最新情况列表
  • 鹤壁哪有做网站的合肥网络优化推广公司
  • idc网站模版抖音seo推荐算法
  • 软件定制开发 报价杭州百度人工优化
  • 做网站最好的软件客源引流推广app
  • 大连网站制作的公司哪家好浏览器地址栏怎么打开
  • 餐饮美食网站模板源码怎么做网站卖产品
  • 拜师做网站宁波网络推广公司有哪些
  • 河南郑州网站建设站长工具端口检测
  • 南昌网站建设公司指数是什么
  • 阿里培训网站建设站长工具网
  • 南通网站建设制作seo分析seo诊断
  • 做海淘的网站如何优化seo
  • 如何查看网站是否被k营销咨询师
  • 如花建站做百度推广代运营有用吗