Skip to content

(google-generativeai: 0.8.1) Send the transparency PNG but look like the "gemini-pro" convert it to jpg. #567

@Pjumpod

Description

@Pjumpod

Description of the bug:

My code is

> if imageext.upper() == ".PNG":
>         print("Make blank")
>         rez_img = rez_img.convert("RGBA")
>         print(rez_img.mode)
>         resize_img_path = os.path.join(save_path,"rez_" + os.path.basename(img_path))
>         rez_img.save(resize_img_path)
>         rez_img = pilimg.open(img_path)
>         print(getattr(rez_img, "get_format_mimetype", None))
>     model_use = genai.GenerativeModel(model_name=model)
>     try:
>         response = model_use.generate_content([system_prompt, rez_img], safety_settings=safety_settings)
>         response_text = str(response.text)
>     except Exception as e:
>         response_text = str(f"{e}")

image
image

and here is the output/
`

Make blank
RGBA
<bound method ImageFile.get_format_mimetype of <PIL.PngImagePlugin.PngImageFile image mode=RGBA size=3375x1894 at 0x1A0F83C6E80>>

`
image

From this link, It should upload from generate_content as PNG and transparency mode.
as show in #523 but when I got the output of "describe the image", I found the word, "on black background" which is mean the PNG with RGBA was convert to RGB.

Actual vs expected behavior:

expect to upload as PNG with RGBA.
but actual still RGB.

image
image

Any other information you'd like to share?

google-generativeai 0.8.1

ByeIO may not able to decode the alpha channel of an image.
I attached this in the code review.
image
and Here is from stackoverflow.

Metadata

Metadata

Assignees

Labels

component:apiIssues related to the API, not the SDK.status:triagedIssue/PR triaged to the corresponding sub-teamtype:bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions