send PIL.Image to django server side and get it back

José María Mateos chema at
Thu Jul 19 18:49:14 EDT 2018

On Mon, Jul 16, 2018 at 06:40:45AM -0700, Christos Georgiou - ΤΖΩΤΖΙΟΥ wrote:
> You need first to serialize the object to bytes that can go over the 
> wire. There is no predefined way to do that, so you can:
> >>> import io
> >>> file_like_object = io.BytesIO()
> >>>, format='png')
> and then in your POST request send file_like_object.getvalue() as the 
> image data.  You will most probably need to add a Content-Type: 
> image/png as a header.

If you definitely need to send the data as a string, because you want to 
use a JSON object or similar, I've done this in the past using base64 


José María (Chema) Mateos ||

More information about the Python-list mailing list