Skip to Content
Menu
This question has been flagged
1469 Zobrazenia

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
Zrušiť
Related Posts Replies Zobrazenia Aktivita
1
okt 24
10619
1
jún 19
5576
1
máj 25
1218
2
dec 23
13738
0
okt 23
33