Heim >Backend-Entwicklung >Python-Tutorial >python实现通过pil模块对图片格式进行转换的方法

python实现通过pil模块对图片格式进行转换的方法

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-10 15:16:591181Durchsuche

本文实例讲述了python实现通过pil模块对图片格式进行转换的方法。分享给大家供大家参考。具体分析如下:

python的pil模块相当的智能,如果你需要对图片格式进行转换,比如jpg转转成tif,jpg转换成gif,png转换成jpg只需要在保存文件时指定正确的图片扩展名即可。

代码如下:

import Image
im = Image.open('test.jpg')
im.save('test.tiff') # or 'test.tif'

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

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn