[Image-SIG] Re: Image.putpalette() bug
Thu, 1 May 2003 14:09:13 +0200
"Derek Simkowiak" <email@example.com> wrote:
> I was testing my WalImagePlugin.py file, and got a strange
> message when I tried to "show()" it:
> class WalImageFile(ImageFile.ImageFile):
> format = "WAL"
> format_description = "Id Software Quake WAL texture map"
> def _open(self):
> Image.register_open("WAL", WalImageFile)
> Image.register_extension("WAL", ".wal")
this won't work: PIL requires file plugins to be able to identify a file
by looking at the contents, and there's no identifying information in
a WAL file.
why not just use the WalImageFile module from 1.1.4b1? (which is
pretty much identical to the one I posted, and appears to work with
all WAL samples I've checked).
in your program, you could do something like:
im = WalImageFile.open(filename)
... get transparency setting ...
if transparency is not None:
im = im.convert("RGBA")
im.putalpha(Image.new("L", im.size, 255*transparency)