grafik formats
Gerhard W. Gruber
g.gruber at xsoft.co.at
Thu Sep 2 05:35:55 EDT 1999
David Oppenheimer wrote:
> http://www.pythonware.com/library/pil/handbook/pilconvert.htm
>
> The PIL is supposed to work for converting from one image format to
> another. If you are using PIL with Win95/98/NT and Pythonwin and are able
> to get it to work, please let me know how you did it
I just figured it out.
I don't know if this is the "proper" solution so i post it to the NG as
well and maybe somebody can point out if there is a better way to do it.
You download the package and unpack it into your python installation
directory.
Now you should have a path like this: d:\Program Files\Python\PIL
In the PIL directory you must copy the following file and name it
__init__.py This seems to be a default name when you want to import a
file, you have to have it in your directory.
snip------------------------------------------------------------------------------------------
#----------------------------------------------------------------------------
# Name: __init__.py
# Purpose: The presence of this file turns this directory into a
# Python package.
#
# Author: Robin Dunn
#
# Created: 8/8/98
# RCS-ID: $Id: __init__.py,v 1.4 1999/06/22 07:03:01 RD Exp $
# Copyright: (c) 1998 by Total Control Software
# Licence: wxWindows license
#----------------------------------------------------------------------------
# ensure the main extension module is loaded, in case the embedded
modules
# (such as utils,) are used standalone. This hack should go away soon.
import Image
from JpegImagePlugin import *
#----------------------------------------------------------------------------
snip------------------------------------------------------------------------------------------
As you see the last line contains the JpegImagePlugin import statement.
You have a number of similar *.py files in the PIL directory. You must
import every file format you want to use, because from a look at the
python code I noticed that there is a register function which loads the
appropriate gfx file driver. If you always use all file formats you
should place the imrpot statements in the __init_.py file, otherwise you
must import them manually where you need them after "import Image".
Hope this helps.
>>> from PIL import Image
>>> im = Image.open("e:\\gfx\\Desolation.jpg")
>>> print im.format, im.size, im.mode
JPEG (384, 480) RGB
>>>
--
bye,
Gerhard
email: sparhawk at eunet.at
g.gruber at xsoft.co.at
More information about the Python-list
mailing list