Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

available formats and params for Image.save()

0 views
Skip to first unread message

News123

unread,
Jul 23, 2009, 5:56:45 AM7/23/09
to
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

Gabriel Genellina

unread,
Jul 24, 2009, 5:47:37 AM7/24/09
to pytho...@python.org
En Thu, 23 Jul 2009 06:56:45 -0300, News123 <new...@free.fr> escribi�:

> 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

--
Gabriel Genellina

News123

unread,
Jul 25, 2009, 4:29:29 PM7/25/09
to
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

0 new messages