Pular para o conteúdo
Menu
Esta pergunta foi sinalizada
1484 Visualizações

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
Cancelar
Publicações relacionadas Respostas Visualizações Atividade
1
out. 24
10627
1
jun. 19
5577
1
mai. 25
1246
2
dez. 23
13768
0
out. 23
33