* Process canvas to blob URL for thumbnails.
(canvas: HTMLCanvasElement | OffscreenCanvas)
| 13 | * Process canvas to blob URL for thumbnails. |
| 14 | */ |
| 15 | async function canvasToBlobUrl(canvas: HTMLCanvasElement | OffscreenCanvas): Promise<string | null> { |
| 16 | return new Promise((resolve) => { |
| 17 | if (isOffscreenCanvas(canvas)) { |
| 18 | canvas.convertToBlob({ type: 'image/jpeg', quality: 0.75 }).then((blob) => { |
| 19 | resolve(URL.createObjectURL(blob)); |
| 20 | }).catch(() => { |
| 21 | resolve(null); |
| 22 | }); |
| 23 | } else { |
| 24 | canvas.toBlob((blob) => { |
| 25 | if (blob) { |
| 26 | resolve(URL.createObjectURL(blob)); |
| 27 | } else { |
| 28 | resolve(null); |
| 29 | } |
| 30 | }, 'image/jpeg', 0.75); |
| 31 | } |
| 32 | }); |
| 33 | } |
| 34 | |
| 35 | // Create the thumbnail cache instance |
| 36 | const thumbnailCache = createImageCache<string>({ |
nothing calls this directly
no test coverage detected