raster (PIL)
Peter Otten
__peter__ at web.de
Thu Jul 23 10:19:38 EDT 2009
superpollo wrote:
> 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?
Of course. Think of it as a shortcut for
tmp = im.convert(...)
tmp.save(...)
del tmp
Peter
More information about the Python-list
mailing list