[Image-SIG] WG: How to create instance of Image ?
Fredrik Lundh
fredrik@pythonware.com
Wed, 16 Jun 1999 13:05:57 +0200
Graf Patrick <pg@puggy.com> wrote:
> maybe a simple problem, if you know the solution....
>
> I'm trying to write a class for my own image processing needs.
> In this matter, I'm having problems with some variable declarations
> I'd like to create a image variable, let's call it myPicture .
>
> So I tried to declare
>
> myPicture = Image.Image()
what made you think you could write that? ;-)
the only way to create new images in PIL is to use
a factory function; the two most commonly used
functions are Image.open and Image.new.
see the docs for more info:
http://www.pythonware.com/library/pil/handbook/image.htm
> Note: Is it possible to use an Image object and pass it to a procedure ?
pass it do a Python function? sure. like,
say:
def procedure(im):
im.save("out.jpg")
procedure(Image.open("in.ppm"))
</F>