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