Read / Write image file
phil
phillip.watts at anvilcom.com
Tue May 3 14:47:42 EDT 2005
> I have a image file on my pc, say a .jpg. Basically I want to setup a
> client/server socket, and I want the client to read in the jpg and send
> it to the server, where the server can write that data into a new file
> on the server.
>
> I tried just doing something like..
>
> x = open("abc.jpg")
> y = x.read()
> tmp = open("newFile.jpg", "w")
> tmp.write(y)
> tmp.close()
> x.close()
>
> ...but that doesn't give me a copy of abc.jpg
>
> any ideas? Thanks
>
What in the world does it give you?
If this is Windoze you should open x "rb"
and tmp "wb", otherwise it will expand linefeeds.
More information about the Python-list
mailing list