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

iMath redstone-cold at 163.com
Mon Jul 16 08:51:57 EDT 2018


I also posted the question here
https://stackoverflow.com/questions/51355926/send-pil-image-to-django-server-side-and-get-it-back

I don't know what's under the hood of sending an image from client side to server side, so stuck by the following scenario.

I want to send a PIL.Image object to django server side using the Python requests lib and get it back in order to use the PIL.Image object on server side. As I have tested , if sent the PIL.Image object without any conversion , that is

r = requests.post(SERVER_URL,
                data={
                    'image': PILimage,#PILimage is of type PIL.Image
                    'wordPos':(86,23)
                    },
                )
then I just got a str object with value  <PIL.PngImagePlugin.PngImageFile image mode=RGB size=149x49 at 0x13F25D0> on server side, I guess it was caused by  requests, which converted the PIL.Image object to a str object before sending, so why  requestsdo the conversion ? why cannot we send the PIL.Image object without any conversion over the Internet ? please give some explanation here, thanks!



More information about the Python-list mailing list