available formats and params for Image.save()

N

News123

Hi,

Somehow I have difficulties reading the documentation for PIL (Image)

Is there an easy way to know which formats are supported and what their
names are?

Is there an easy way to know which parameters are supported by
Image.save(). How can I list them where are they documented?


Somehow I consider the documentation to be a little weak on this points.
all the documentation says (at least where I looked) is:
class Image
| Methods defined here:
. . .
save(self, fp, format=None, **params)
| Save image to file or stream

In order to find out how the format name for a .jpg file I did following:

import Image
img = Image.open("afile.jpg")
print img.format


Then I saw, that the result was 'JPEG' and not 'JPG' as I tried first

I'm at a complete loss at finding out what parameters the save function
accepts for saving a JPG file or a PNG file

Is there an easy way of finding this in any doc or do I have to dive
into the sources.


If there's no easy way:
Wouldn't a better documentation increase the 'user experience'?



Thanks in advance for any pointers


N
 
G

Gabriel Genellina

Somehow I have difficulties reading the documentation for PIL (Image)

Is there an easy way to know which formats are supported and what their
names are?

py> import PIL
py> from PIL import Image
py> Image.ID
[]
py> Image.init()
py> Image.ID
['PNG', 'ARG', 'BMP', 'BUFR', 'CUR', 'PCX', 'DCX', 'EPS', 'FITS', 'FLI',
'FPX',
'GBR', 'GIF', 'GRIB', 'HDF5', 'ICNS', 'ICO', 'IM', 'IMT', 'IPTC', 'JPEG',
'MCIDA
S', 'TIFF', 'MIC', 'MPEG', 'MSP', 'PCD', 'PIXAR', 'PPM', 'PSD', 'SGI',
'SPIDER',
'SUN', 'TGA', 'WBMP', 'WMF', 'XBM', 'XPM', 'XVTHUMB']
py> Image.OPEN.keys()
['PCX', 'ICNS', 'HDF5', 'SUN', 'MIC', 'EPS', 'MSP', 'FLI', 'FITS', 'GBR',
'WBMP'
, 'PCD', 'PIXAR', 'BUFR', 'PPM', 'WMF', 'SGI', 'BMP', 'TGA', 'DCX', 'ICO',
'CUR'
, 'XPM', 'TIFF', 'JPEG', 'SPIDER', 'GIF', 'GRIB', 'IM', 'IMT', 'IPTC',
'FPX', 'X
BM', 'MPEG', 'PSD', 'ARG', 'XVTHUMB', 'PNG', 'MCIDAS']
py> Image.SAVE.keys()
['XBM', 'PCX', 'SPIDER', 'HDF5', 'TIFF', 'BUFR', 'EPS', 'JPEG', 'MSP',
'GRIB', '
GIF', 'BMP', 'IM', 'PPM', 'PDF', 'FITS', 'PALM', 'WBMP', 'WMF', 'PNG']
Is there an easy way to know which parameters are supported by
Image.save(). How can I list them where are they documented?

That depends on the format being used. The PIL handbook lists the standard
formats used and their parameters:
http://www.pythonware.com/library/pil/handbook/index.htm
I'm at a complete loss at finding out what parameters the save function
accepts for saving a JPG file or a PNG file

http://www.pythonware.com/library/pil/handbook/format-jpeg.htm
 
N

News123

Thanks a lot Gabriel,

Your answer is perfect.

I was only looking in part II of the PIL manual and overlooked the
Appendix :-(.

I also apreciate
Image.ID , Image.SAVE , Image.OPEN

I saw them when typing
dir Image
but I never had the idea of calling Image.init() first

bye

N




Gabriel said:
Somehow I have difficulties reading the documentation for PIL (Image)

Is there an easy way to know which formats are supported and what their
names are?

py> import PIL
py> from PIL import Image
py> Image.ID
[]
py> Image.init()
py> Image.ID
['PNG', 'ARG', 'BMP', 'BUFR', 'CUR', 'PCX', 'DCX', 'EPS', 'FITS', 'FLI',
'FPX',
'GBR', 'GIF', 'GRIB', 'HDF5', 'ICNS', 'ICO', 'IM', 'IMT', 'IPTC',
'JPEG', 'MCIDA
S', 'TIFF', 'MIC', 'MPEG', 'MSP', 'PCD', 'PIXAR', 'PPM', 'PSD', 'SGI',
'SPIDER',
'SUN', 'TGA', 'WBMP', 'WMF', 'XBM', 'XPM', 'XVTHUMB']
py> Image.OPEN.keys()
['PCX', 'ICNS', 'HDF5', 'SUN', 'MIC', 'EPS', 'MSP', 'FLI', 'FITS',
'GBR', 'WBMP'
, 'PCD', 'PIXAR', 'BUFR', 'PPM', 'WMF', 'SGI', 'BMP', 'TGA', 'DCX',
'ICO', 'CUR'
, 'XPM', 'TIFF', 'JPEG', 'SPIDER', 'GIF', 'GRIB', 'IM', 'IMT', 'IPTC',
'FPX', 'X
BM', 'MPEG', 'PSD', 'ARG', 'XVTHUMB', 'PNG', 'MCIDAS']
py> Image.SAVE.keys()
['XBM', 'PCX', 'SPIDER', 'HDF5', 'TIFF', 'BUFR', 'EPS', 'JPEG', 'MSP',
'GRIB', '
GIF', 'BMP', 'IM', 'PPM', 'PDF', 'FITS', 'PALM', 'WBMP', 'WMF', 'PNG']
Is there an easy way to know which parameters are supported by
Image.save(). How can I list them where are they documented?

That depends on the format being used. The PIL handbook lists the
standard formats used and their parameters:
http://www.pythonware.com/library/pil/handbook/index.htm
I'm at a complete loss at finding out what parameters the save function
accepts for saving a JPG file or a PNG file

http://www.pythonware.com/library/pil/handbook/format-jpeg.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top