Hi
Using the camera example for python here I added
actual code to the buffer callback to actually save a picture, like so:
The problem is that the picture turns out in grayscale. If I set the mode for the fromstring method to "RGB" or "CMYK" it gives a "ValueError: not enough image data" error, and only the "P" mode seems to work. This seems odd as looking at the size of the buffer recieved (as a string) it is definately big enough for a colour image at 640*480. Does anyone have any clue what's going on?Code:def buffer_cb(self, element, buffer, pad): if self.picture_taken: self.picture_taken = False print "picture taken" image = Image.fromstring("P", (640,480), buffer) image = image.convert("RGB") image.save("picture.jpg") return True
Thanks in advance

Reply With Quote

