in content_api.py [0:0]
def pil_image(self) -> PIL.Image.Image:
"""Returns PIL.Image representation of the Part."""
if not mime_types.is_image(self.mimetype):
raise ValueError(f'Part is not an image. Mime type is {self.mimetype}.')
bytes_io = io.BytesIO()
if self.part.inline_data is not None:
bytes_io.write(self.part.inline_data.data)
bytes_io.seek(0)
return PIL.Image.open(bytes_io)