Open
Description
figure.export()
will only work if show()
is called first and export()
is called in a separate cell.
This works:
import fastplotlib as fpl
import numpy as np
random_3d = np.random.randn(100, 100, 100)
iw = fpl.ImageWidget(data=random_3d)
iw.show()
iw.figure.export('./random.png')
This does not:
import fastplotlib as fpl
import numpy as np
random_3d = np.random.randn(100, 100, 100)
iw = fpl.ImageWidget(data=random_3d)
iw.show()
iw.figure.export('./random.png')
iw.close()
AttributeError Traceback (most recent call last)
Cell In[12], line 9
7 iw = lcp.plot_contours(cnmf_df, -1)
8 iw.show()
----> 9 iw.figure.export('./test.png')
10 iw.close()
12 # lcp.save_contours(cnmf_df, -1, './test.png')
File [~/miniforge3/envs/lcp/lib/python3.10/site-packages/fastplotlib/layouts/_figure.py:596](http://localhost:8888/home/flynn/miniforge3/envs/lcp/lib/python3.10/site-packages/fastplotlib/layouts/_figure.py#line=595), in Figure.export(self, uri, **kwargs)
590 raise ImportError(
591 "imageio is required to use Figure.export(). Install it using pip or conda:\n"
592 "pip install imageio\n"
593 "conda install -c conda-forge imageio\n"
594 )
595 else:
--> 596 snapshot = self.renderer.snapshot()
597 remove_alpha = True
599 # image formats that support alpha channel:
600 # https://en.wikipedia.org/wiki/Alpha_compositing#Image_formats_supporting_alpha_channels
File ~/miniforge3/envs/lcp/lib/python3.10/site-packages/pygfx/renderers/wgpu/engine/renderer.py:789, in WgpuRenderer.snapshot(self)
786 """Create a snapshot of the currently rendered image."""
788 # Prepare
--> 789 texture = self._blender.color_tex
790 size = texture.size
791 bytes_per_pixel = 4
AttributeError: 'Ordered2FragmentBlender' object has no attribute 'color_tex'
This is more of an issue when I have built an image widget in a separate function, I'd like to save a image of the widget before returning it to the user without needing to render it.
Is this possible?
Metadata
Metadata
Assignees
Labels
No labels