Skip to Content
Menu
This question has been flagged

Hi guys!, i'm trying to merge two images previously stored in odoo fields. To do that, i'm using PIL library in this way:


Get and transform both images in PIL Image objects:

image_pil_1 = Image.open(BytesIO(base64.b64decode(image_odoo_1)))

image_pil_2 = Image.open(BytesIO(base64.b64decode(image_odoo_2)))


Then i deal with these images to generate final PIL Image object (i simply use blend method):

image_pil_final = Image.blend(image_pil_1, image_pil_2, 0.5)


Finally, transform and return final image in b64encode:

return base64.b64encode(image_pil_final.tobytes())


This return statement gives back (technically) the image to display into a binary field stored in my odoo db in the following way:

<field name="product_img" readonly="1" nolabel="1" widget="image"/>


But i'm getting this error:

"The selected image could not be displayed!"

 

I would like to ask what's wrong with my code and how's the correct way to achieve this. Thanks so much in advance and wait for any help!



Avatar
Discard
Related Posts Replies Views Activity
1
Aug 21
4965
1
Sep 20
4728
0
Jul 19
216
2
Dec 18
3204
5
Nov 18
6806