diff --git a/eomaps/eomaps.py b/eomaps/eomaps.py index 6fa41ab43..6d43f01ab 100644 --- a/eomaps/eomaps.py +++ b/eomaps/eomaps.py @@ -3462,21 +3462,13 @@ def snapshot(self, *layer, transparent=False, clear=False): else: sn = self._get_snapshot() try: - from IPython.display import display, Image as IpyImage - from io import BytesIO - - # fix issues with PILLOW 10.0 and transparent snapshots - # in jupyter notebooks (TODO should be fixed in PILLOW 10.1.0) - # ...bug causes unwanted errors in _repr__jpeg_ for RGBA images - # the fix enforces png as format - temp = BytesIO() - Image.fromarray(sn, "RGBA").save(temp, format="png") - - display( - IpyImage(temp.getvalue()), - display_id=True, - clear=clear, - ) + from IPython.display import display_png, clear_output + + if clear: + clear_output(wait=True) + # use display_png to avoid issues with transparent snapshots + display_png(Image.fromarray(sn, "RGBA"), raw=False) + except Exception: _log.exception( "Unable to display the snapshot... is the script "