Python implements the method of converting image formats through the pil module

  • 2020-04-02 14:43:13
  • OfStack

This article illustrates an example of how python implements a pil module to convert image formats. Share with you for your reference. Specific analysis is as follows:

Python's pil module is quite smart, if you need to convert the image format, such as JPG to tif, JPG to GIF, PNG to JPG just need to specify the correct image extension when saving the file.

The code is as follows:


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

I hope this article has helped you with your Python programming.


Related articles: