python中图像的格式转换 [英] format conversion of an image in python

查看:351
本文介绍了python中图像的格式转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须编写一个使用python进行图像处理的应用程序. 有谁知道如何将图像的文件类型从JPEG转换为TIFF?

I have to write an application for image processing in python. does anyone know how to convert the file type of an image from JPEG to TIFF?

推荐答案

查看 Python图像库(PIL).参见教程,PIL易于使用.

Check out the Python Image Library (PIL). See this tutorial, the PIL is quite easy to use.

受支持的图像格式.

要进行转换,请打开图像,然后将其保存为新的扩展名(PIL使用该扩展名来确定用于保存的格式).

To do the conversion you open the image and then save it with the new extension (which PIL uses to determine what format to use for saving).

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

请注意,官方发行版尚不支持Python 3.x(但?),但是至少在Windows下存在

Note that the official distribution does not support Python 3.x (yet?), however, at least under Windows there's an unofficial version available that works with v 3.x.

这篇关于python中图像的格式转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆