[Tutor] XML-RPC data transfers.

Kent Johnson kent37 at tds.net
Sun Dec 31 03:22:24 CET 2006


Luke Paireepinart wrote:

> But the main strategy is to get the data out of the ImageGrab object.
> one way is stated above - use the save method to write to a file.
> another possible way is to create a filelike class, implementing 'tell' 
> 'seek' and 'write' methods, that just collects all the data written to 
> it and keeps it in memory
> rather than writing it out to a file.
> This is hinted at in the documentation for im.save():
> "You can use a file object instead of a filename. In this case, you must 
> always specify the format. The file object must implement the *seek*, 
> *tell*, and *write* methods, and be opened in binary mode."
> (I assume it means you can use a file-like object, also, but it's 
> possible that you can't, and I leave it to you to test that :) )

You can probably use a StringIO or cStringIO object instead of an actual 
file.

> a third solution is to convert the data to a string using
> *im.tostring().
> *send that over your connection, and use im.fromstring() on the other 
> end to recreate the image.

That sounds like a good plan too.

Kent



More information about the Tutor mailing list