• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >python > python通过pil模块将raw图片转换成png图片的方法

python通过pil模块将raw图片转换成png图片的方法

作者: 字体:[增加 减小] 来源:互联网

通过本文主要向大家介绍了python3 pil,python pil,python中pil,python pil安装,python3.5 pil等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

本文实例讲述了python通过pil模块将raw图片转换成png图片的方法。分享给大家供大家参考。具体分析如下:

python通过pil模块将raw图片转换成png图片,pil中包含了fromstring函数可以按照指定模式读取图片信息然后进行保存。

rawData = open("foo.raw" 'rb').read()
imgSize = (x,y)
# Use the PIL raw decoder to read the data.
# the 'F;16' informs the raw decoder that we are reading 
# a little endian, unsigned integer 16 bit data.
img = Image.fromstring('L', imgSize, rawData, 'raw', 'F;16')
img.save("foo.png")
</div>

其中Image.fromstring函数的第一个参数具体含义如下

1 (1-bit pixels, black and white, stored with one pixel per byte)
L (8-bit pixels, black and white)
P (8-bit pixels, mapped to any other mode using a colour palette)
RGB (3x8-bit pixels, true colour)
RGBA (4x8-bit pixels, true colour with transparency mask)
CMYK (4x8-bit pixels, colour separation)
YCbCr (3x8-bit pixels, colour video format)
I (32-bit signed integer pixels)
F (32-bit floating point pixels)

希望本文所述对大家的Python程序设计有所帮助。

</div>

您可能想查找下面的文章:

  • Python实现更改图片尺寸大小的方法(基于Pillow包)
  • python安装PIL模块时Unable to find vcvarsall.bat错误的解决方法
  • Python基于pillow判断图片完整性的方法
  • Python基于pillow判断图片完整性的方法
  • Linux上安装Python的PIL和Pillow库处理图片的实例教程
  • python中PIL安装简单教程
  • Python使用PIL库实现验证码图片的方法
  • Python使用PIL库实现验证码图片的方法
  • 使用Python的PIL模块来进行图片对比
  • 使用Python的PIL模块来进行图片对比

相关文章

  • python获取当前用户的主目录路径方法(推荐)
  • 总结Python编程中三条常用的技巧
  • Python 基础教程之包和类的用法
  • Python中__name__的使用实例
  • python使用BeautifulSoup分页网页中超链接的方法
  • Python3 能振兴 Python的原因分析
  • python笔记(1) 关于我们应不应该继续学习python
  • python中的reduce内建函数使用方法指南
  • 使用Python编写提取日志中的中文的脚本的方法
  • Python实现的监测服务器硬盘使用率脚本分享

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • Python中列表和元组的使用方法和区别详解
    • Python Socket编程详细介绍
    • 用Python编写脚本使IE实现代理上网的教程
    • 分析Python的Django框架的运行方式及处理流程
    • Python异常学习笔记
    • Python 登录网站详解及实例
    • Python实现提取文章摘要的方法
    • python处理文本文件并生成指定格式的文件
    • python实现斐波那契数列的方法示例
    • python同义词替换的实现(jieba分词)

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有