( base64: string, format: string = "png", width?: number, height?: number, )
| 121 | }; |
| 122 | |
| 123 | export function decodeBase64Image( |
| 124 | base64: string, |
| 125 | format: string = "png", |
| 126 | width?: number, |
| 127 | height?: number, |
| 128 | ): HTMLImageElement { |
| 129 | const img = new Image(); |
| 130 | if (width != null) { |
| 131 | img.width = width; |
| 132 | } |
| 133 | if (height != null) { |
| 134 | img.height = height; |
| 135 | } |
| 136 | const mime = mimeTypes[format] || `image/${format}`; |
| 137 | img.src = `data:${mime};base64,${base64}`; |
| 138 | return img; |
| 139 | } |
| 140 | |
| 141 | /** |
| 142 | * Decode an encoded array into a binary array |
no outgoing calls
no test coverage detected