grafik formats

Robin Dunn robin at alldunn.com
Thu Sep 2 18:20:08 EDT 1999


>
> 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------------------------------------------------------------------------
------------------
>

Now this is interesting...  Seeing some wxPython sources (well a header
anyway) with my name on it used with PIL, a totally unrelated package,
submitted by a totally unrelated person...  Weird.

Anyway, the presence of __init__.py simply turns a directory into a Python
Package, and lets you do package type things with it, (like from
<package_name> import <module>.)  See
http://www.python.org/doc/essays/packages.html  for more info.

If I remember correctly, PIL is not organized as a package.   So the PIL
directory itself should be added to your PYTHONPATH either in the
environment or in the registry.  Then you can do "import Image" and "from
JpegImagePlugin import *" directly in your code.


--
Robin Dunn
Software Craftsman
robin at AllDunn.com
http://AllDunn.com/robin/
http://AllDunn.com/wxPython/  Check it out!







More information about the Python-list mailing list