Skip to content

Commit

Permalink
notebook run_nb: save image as jpg only
Browse files Browse the repository at this point in the history
  • Loading branch information
pthom committed Dec 18, 2024
1 parent f7e1dc4 commit db76618
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion bindings/imgui_bundle/immapp/immapp_notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,26 @@ def make_thumbnail(image):
thumbnail_image = image
return thumbnail_image

# def display_image(image):
# pil_image = PIL.Image.fromarray(image)
# display(pil_image)

def display_image(image):
from IPython.display import Image

# Convert the input image to a PIL image
pil_image = PIL.Image.fromarray(image)
display(pil_image)

# Save the PIL image to a bytes buffer in PNG format
import io
buffer = io.BytesIO()
pil_image.save(buffer, format="JPEG")
buffer.seek(0)

# Create an IPython display Image object and specify PNG format
jpeg_image = Image(data=buffer.getvalue(), format="jpeg")
display(jpeg_image)


def run_app_and_display_thumb():
nonlocal thumbnail_ratio
Expand Down

0 comments on commit db76618

Please sign in to comment.