Skip to content

Commit fb9995c

Browse files
committed
Merge branch 'main' into caching
Change-Id: I2bade6b0099f12dd37a24fe26cfda1981c58fbc0
2 parents 4627fe1 + 7b9758f commit fb9995c

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

google/generativeai/types/content_types.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272

7373
def pil_to_blob(img):
7474
bytesio = io.BytesIO()
75-
if isinstance(img, PIL.PngImagePlugin.PngImageFile):
75+
if isinstance(img, PIL.PngImagePlugin.PngImageFile) or img.mode == "RGBA":
7676
img.save(bytesio, format="PNG")
7777
mime_type = "image/png"
7878
else:

google/generativeai/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
# limitations under the License.
1515
from __future__ import annotations
1616

17-
__version__ = "0.5.4"
17+
__version__ = "0.6.0"

tests/test_content.py

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import IPython.display
2525
import PIL.Image
2626

27+
import numpy as np
2728

2829
HERE = pathlib.Path(__file__).parent
2930
TEST_PNG_PATH = HERE / "test_img.png"
@@ -67,6 +68,7 @@ class ADataClassWithList:
6768
class UnitTests(parameterized.TestCase):
6869
@parameterized.named_parameters(
6970
["PIL", PIL.Image.open(TEST_PNG_PATH)],
71+
["RGBA", PIL.Image.fromarray(np.zeros([6, 6, 4], dtype=np.uint8))],
7072
["IPython", IPython.display.Image(filename=TEST_PNG_PATH)],
7173
)
7274
def test_png_to_blob(self, image):
@@ -77,6 +79,7 @@ def test_png_to_blob(self, image):
7779

7880
@parameterized.named_parameters(
7981
["PIL", PIL.Image.open(TEST_JPG_PATH)],
82+
["RGB", PIL.Image.fromarray(np.zeros([6, 6, 3], dtype=np.uint8))],
8083
["IPython", IPython.display.Image(filename=TEST_JPG_PATH)],
8184
)
8285
def test_jpg_to_blob(self, image):

0 commit comments

Comments
 (0)