Ir al contenido
Menú
Se marcó esta pregunta
1521 Vistas

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
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
1
oct 24
10666
1
jun 19
5637
1
may 25
1342
2
dic 23
13906
0
oct 23
33