Writing byte stream as jpeg format to disk

Navkirat Singh navkirats at gmail.com
Thu Aug 26 15:54:43 EDT 2010


On 27-Aug-2010, at 12:45 AM, MRAB wrote:

> On 26/08/2010 19:57, Navkirat Singh wrote:
>> I am sorry, maybe I was not elaborate in what I was having trouble
>> with. I am using a jpegcam library, which on my web page captures a
>> webcam image and sends it to the server via the POST method. On the
>> Server side (python 3), I receive this image as a part of header
>> content in bytes (I know thats not how it should be done, but the
>> author has some reason for it), so I first convert the headers to a
>> string so I can separate them. From the separated headers I fish out
>> the content of the image file (which is a string). This is where I
>> get stuck, how am I supposed to convert it back to an image, so I can
>> save as a jpeg on disk.
>> 
> [snip]
> What does that string look like? Try printing out repr(image[ : 100]).
> If it looks like plain bytes, then write it to file. If it looks like a
> series of hex digits, then decode to bytes before writing.
> -- 
> http://mail.python.org/mailman/listinfo/python-list

Thanks MRAB, your suggestions have always been very helpful to me. I shall let you know on what I see.

Regards,
Nav


More information about the Python-list mailing list