File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
google/generativeai/types Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change 73
73
74
74
75
75
def pil_to_blob (img ):
76
+ # When you load an image with PIL you get a subclass of PIL.Image
77
+ # The subclass knows what file type it was loaded from it has a `.format` class attribute
78
+ # and the `get_format_mimetype` method. Convert these back to the same file type.
79
+ #
80
+ # The base image class doesn't know its file type, it just knows its mode.
81
+ # RGBA converts to PNG easily, P[allet] converts to GIF, RGB to GIF.
82
+ # But for anything else I'm not going to bother mapping it out (for now) let's just convert to RGB and send it.
83
+ #
76
84
# References:
77
85
# - file formats: https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html
78
86
# - image modes: https://pillow.readthedocs.io/en/stable/handbook/concepts.html#modes
You can’t perform that action at this time.
0 commit comments