format conversion of an image in python

好久不见. 提交于 2020-04-08 09:21:34

问题


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?


回答1:


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

Supported image formats.

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'

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.




回答2:


Use the Python Imaging Library (PIL).

from PIL import Image
img = Image.open('image.jpeg')
img.save('image.tiff')

Ref: http://effbot.org/imagingbook/image.htm




回答3:


Did you try to use PIL ? It can support many image file format.



来源:https://stackoverflow.com/questions/11137120/format-conversion-of-an-image-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!