Skip to Content
Menu
This question has been flagged
1003 Views

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
Oct 24
9678
1
Jun 19
4876
0
Feb 24
458
2
Dec 23
11994
0
Oct 23
33