Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Imaging Library save function syntax

Simple one I think but essentially I need to know what the syntax is for the save function on the PIL. The help is really vague and I can't find anything online. Any help'd be great, thanks :).

like image 983
user33061 Avatar asked Feb 18 '09 19:02

user33061


People also ask

How do you save an image in Python?

Saving an image in Python is just as simple. You simply call save() and pass in the name you want used to save your image. This method will save the image in the format identified by the extension on the filename you pass in.

How do I save a PNG in Python?

The PIL module is used for storing, processing, and displaying images in Python. To save images, we can use the PIL. save() function. This function is used to export an image to an external file.

What is PIL image format?

Python Imaging Library is a free and open-source additional library for the Python programming language that adds support for opening, manipulating, and saving many different image file formats. It is available for Windows, Mac OS X and Linux. The latest version of PIL is 1.1.


1 Answers

From the PIL Handbook:

im.save(outfile, options...)

im.save(outfile, format, options...)

Simplest case:

im.save('my_image.png')

or whatever. In this case, the type of the image will be determined from the extension. Is there a particular problem you're having? Or specific saving option that you'd like to use but aren't sure how to do so?

You may be able to find additional information in the documentation on each filetype. The PIL Handbox Appendixes list the different file types that are supported. In some cases, options are given for save. For example, on the JPEG file format page, we're told that save supports

  • quality
  • optimize, and
  • progressive

with notes about each option.

like image 110
Blair Conrad Avatar answered Oct 26 '22 23:10

Blair Conrad