python通過pil模塊將raw圖片轉(zhuǎn)換成png圖片的方法
本文實(shí)例講述了python通過pil模塊將raw圖片轉(zhuǎn)換成png圖片的方法。分享給大家供大家參考。具體分析如下:
python通過pil模塊將raw圖片轉(zhuǎn)換成png圖片,pil中包含了fromstring函數(shù)可以按照指定模式讀取圖片信息然后進(jìn)行保存。
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函數(shù)的第一個(gè)參數(shù)具體含義如下
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)
希望本文所述對(duì)大家的Python程序設(shè)計(jì)有所幫助。
- python通過pil將圖片轉(zhuǎn)換成黑白效果的方法
- Python圖片轉(zhuǎn)換成矩陣,矩陣數(shù)據(jù)轉(zhuǎn)換成圖片的實(shí)例
- python3圖片轉(zhuǎn)換二進(jìn)制存入mysql
- python使用reportlab實(shí)現(xiàn)圖片轉(zhuǎn)換成pdf的方法
- Python將圖片轉(zhuǎn)換為字符畫的方法
- python如何將圖片轉(zhuǎn)換為字符圖片
- python使用PythonMagick將jpg圖片轉(zhuǎn)換成ico圖片的方法
- 利用python將圖片轉(zhuǎn)換成excel文檔格式
- 利用python和ffmpeg 批量將其他圖片轉(zhuǎn)換為.yuv格式的方法
- python實(shí)現(xiàn)圖片轉(zhuǎn)換成素描和漫畫格式
相關(guān)文章
查看keras各種網(wǎng)絡(luò)結(jié)構(gòu)各層的名字方式
這篇文章主要介紹了查看keras各種網(wǎng)絡(luò)結(jié)構(gòu)各層的名字方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2020-06-06django 快速啟動(dòng)數(shù)據(jù)庫客戶端程序的方法示例
這篇文章主要介紹了django 快速啟動(dòng)數(shù)據(jù)庫客戶端程序的方法示例,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-08-08Python字符串、元組、列表、字典互相轉(zhuǎn)換的方法
這篇文章主要介紹了Python字符串、元組、列表、字典互相轉(zhuǎn)換的方法的相關(guān)資料,需要的朋友可以參考下2016-01-01python實(shí)現(xiàn)簡單的tcp 文件下載
這篇文章主要介紹了python如何實(shí)現(xiàn)簡單的tcp文件下載,幫助大家更好的理解和學(xué)習(xí)python,感興趣的朋友可以了解下2020-09-09