| 39 | } |
| 40 | |
| 41 | function extractImage( |
| 42 | data: Record<string, unknown>, |
| 43 | ): NotebookOutputImage | undefined { |
| 44 | if (typeof data['image/png'] === 'string') { |
| 45 | return { |
| 46 | image_data: data['image/png'].replace(/\s/g, ''), |
| 47 | media_type: 'image/png', |
| 48 | } |
| 49 | } |
| 50 | if (typeof data['image/jpeg'] === 'string') { |
| 51 | return { |
| 52 | image_data: data['image/jpeg'].replace(/\s/g, ''), |
| 53 | media_type: 'image/jpeg', |
| 54 | } |
| 55 | } |
| 56 | return undefined |
| 57 | } |
| 58 | |
| 59 | function processOutput(output: NotebookCellOutput) { |
| 60 | switch (output.output_type) { |