raster (PIL)

superpollo user at example.net
Thu Jul 23 09:57:03 EDT 2009


Peter Otten wrote:
> superpollo wrote:
> 
> 
>>Peter Otten wrote:
>>...
>>
>>>im.convert("1").save(sys.stdout, "PNG")
>>
>>...
>>
>>a q about pil:
>>
>>im.convert("1")
>>
>>is different from:
>>
>>im2 = im.convert("1")
>>
>>right?
>>
>>in the former im is changed (the method applies to im) but in the latter
>>im is unchanged (first im is copied unto im2 and then the method is
>>applied to im2)... am i right?
> 
> 
> No. A method has no clue whether its result is used or discarded. Therefore
> 
> im.convert("1")
> 
> creates a new image in the specified mode, too, which is discarded 
> immediately.

but in:

im.convert("1").save(sys.stdout, "PNG")

the new (anonymous) image created by .convert is not discarded 
*immediately*, i mean *before* the .save method is called on it, right?

bye



More information about the Python-list mailing list