国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

python通過pil模塊將raw圖片轉換成png圖片的方法

2020-02-23 00:21:43
字體:
來源:轉載
供稿:網友

本文實例講述了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")

其中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程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 京山县| 元阳县| 雅安市| 乌海市| 明溪县| 乐山市| 鄂尔多斯市| 庆元县| 绥滨县| 尼玛县| 车险| 义乌市| 都匀市| 曲靖市| 镇雄县| 兴海县| 波密县| 漯河市| 平阳县| 长岭县| 师宗县| 克山县| 满城县| 阳信县| 台安县| 册亨县| 高州市| 澄江县| 电白县| 云安县| 高台县| 平武县| 堆龙德庆县| 清徐县| 凉城县| 那曲县| 巴林左旗| 乐陵市| 台东县| 长岭县| 尚义县|