Convert png bytes to numpy array Example: >>> fig = go.Figure(go.Scatter(x=[1], y=[1])) >>> plt.imshow(png_bytes_to_numpy(fig.to_image('png')))
(png: bytes)
| 16 | |
| 17 | @beartype |
| 18 | def png_bytes_to_numpy(png: bytes) -> npt.NDArray[np.uint8]: |
| 19 | """Convert png bytes to numpy array |
| 20 | |
| 21 | Example: |
| 22 | |
| 23 | >>> fig = go.Figure(go.Scatter(x=[1], y=[1])) |
| 24 | >>> plt.imshow(png_bytes_to_numpy(fig.to_image('png'))) |
| 25 | """ |
| 26 | return np.array(Image.open(BytesIO(png))) |
| 27 | |
| 28 | |
| 29 | class AccessibilityTreeNode(TypedDict): |