[PYTHON IMAGE-SIG] Re: How to derive classes in the Imaging library
Mon, 17 Feb 1997 14:09:50 +0100
> 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:
def __init__(self, mode, size, bg = 0):
# initialize base class part
def _makeself(self, im):
# wrap ImagingCore object in a suitable Python class
IMAGE-SIG - SIG on Image Processing with Python
send messages to: firstname.lastname@example.org
administrivia to: email@example.com