[Image-SIG] using PIL as a package-PIL doesn't load all ImagePlugins-patch?
Fredrik Lundh
fredrik@pythonware.com
Sun, 15 Oct 2000 14:05:05 +0200
Christopher wrote:
> I appear to be having trouble because Image.py:: init() doesn't load the
> plugins appearing in the PIL directory w/o it being on the path.
it's a known bug in 1.1. the usual workaround is to explicitly
import the file formats you need:
from PIL import Image, PngImagePlugin, JpegImagePlugin
(note that PIL successfully imports a couple of plugins if you *open*
a file; it's only a real problem if you're writing out images you've
created internally, or if you're using less common file formats).
:::
> tmppath = sys.path
note that this creates a reference to sys.path, and the following
append will modify sys.path as well. use "tmppath = sys.path[:]"
to create a (shallow) copy.
:::
the "right" way to do this is to use the __path__ variable instead
of sys.path (but only if it exists):
try:
tmppath = __path__
except:
tmppath = sys.path
:::
and yes, this is fixed in the upcoming 1.2 release.
</F>