secepar
Jun 22, 2017 - 15:41
Hi,
I think it is a simple task. I have a button action to take a photo and save it to the local folder as well as the camera roll.
def take_front_action(sender):
console.alert("Take front image", "", "OK")
front_image=photos.capture_image()
photos.save_image(front_image) #saving to camera roll working fine
last_asset=photos.get_assets()[-1]
img=last_asset.get_image()
front_filename=str(ObjCInstance(last_asset).valueForKey_('filename'))
with open(front_filename, 'wb') as out_file:
out_file.write(img)
My code is giving me the following error:
a bytes-linked object is required, not 'Image' or
a bytes-linked object is required, not 'JpegImageFile',
Depending on what I put inside 'img', 'last_asset' or 'front_image'in write().
I think I'm not so clear what file format I'm getting in each function call. Hence the error.
Any help will be greatly appreciated. Many thanks in advance.
Sec