January 24th, 2005, 01:31 PM
send a picture over TCP
I am using python 2.3.3 and have installed PIL http://www.pythonware.com/products/pil/index.htm
I need to send a picture over a tcp socket (jpg). I can't figure out how to do this. Opening the file using builtin open, storing it in a list. Marshal the list (dump =marshal.dumps(list)) and send it to the server. Then unmarshal it (list = marshal.loads(dump)), write the list to a file. Then pray it will be able to view it using xv doesnt sound as the right solution. Correct me if am wrong!
This can't be so hard to accomplish!?
January 24th, 2005, 01:56 PM
Quick question here... why are you serializing the data. Why can't you simply send the raw image data over a socket connection. You could perhaps design your own little protocol if needed, something like this:
IMAGE <imagename> SIZE xxxx
<image data follows>
That way the other end knows what the file name is and what size it should expect. It can then stream the remaining data to a file. You can perhaps add a checksum as well.
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne
"I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
January 24th, 2005, 03:53 PM
Yeah that was what I was looking for Couldn't think right... 12 hours with programming screws up my head sometimes.
January 24th, 2005, 09:46 PM
you should read a nice little slashdot post on over coding... more than 10 hours = bad buggy code... that is unless you are drinking because somehow druken code always seems to compile.