[PYTHON IMAGE-SIG] Re: How to derive classes in the Imaging library
by Fredrik Lundh other posts by this author
Feb 17 1997 11:09PM messages near this date
[PYTHON IMAGE-SIG] Using PyOpenGL on Win95 with PythonWin?
|
[PYTHON IMAGE-SIG] Transparency in TK
> I am trying to derive a new class from class Image in Image.py in
> Fredrik Lundh's PIL (Python Imaging Library). I'm not entirely sure of
> the reasoning behind the Image class structure, but it uses a factory
> function in the module called new to create new instances of class
> Image. This is, I guess, so that images can be created in different
> ways (ie from a file with the open() factory function).
The Image class is just a wrapper for the internal ImagingCore type;
it was never really designed for general subclassing... But as you
pointed out, the _makeself method allows you to get some control over
what all those factory methods in there really returns.
> I guess a different way of looking at it is - Is there any way of
> initialising the baseClass part from a derived class __init__()
> given a already existing instance of the base class?
Maybe you could do something like:
class XImage(Image):
def __init__(self, mode, size, bg = 0):
# initialize base class part
Image.__init__(self)
# whatever
def _makeself(self, im):
# wrap ImagingCore object in a suitable Python class
Cheers /F
_______________
IMAGE-SIG - SIG on Image Processing with Python
send messages to: image-sig@[...].org
administrivia to: image-sig-request@[...].org
_______________
|