Hi, I have a Axis IP camera that I can send a HTTP command to and the data returned is the jpg image.
When I get this data, I want to save it as a .jpg file, but I think my encoding is not correct, because the image is all distorted. I looked at using PIL, but the device I will install my script on can't be used to install other packages like this. I'll have to include the modules in my own folder. Here is my simple code that I started testing with. """ import urllib2 # Create an OpenerDirector with support for Basic HTTP Authentication... auth_handler = urllib2.HTTPBasicAuthHandler() auth_handler.add_password('.', '192.168.10.190', 'root', 'pass') opener = urllib2.build_opener(auth_handler) # ...and install it globally so it can be used with urlopen. urllib2.install_opener(opener) return_object = urllib2.urlopen('http://192.168.10.190/axis-cgi/jpg/image.cgi?resolution=320 x240&squarepixel=1') html_content = return_object.read() img_file = "E:\work\img1.jpg" f = open(img_file, 'w') f.write(html_content) f.close() """ Any ideas what type of encoding I have to use if that is the problem? Thanks Johan
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor