]>
Commit | Line | Data |
---|---|---|
1 | import { logger } from './logger' | |
2 | ||
3 | function imageToDataURL (input: File | Blob) { | |
4 | return new Promise<string>(res => { | |
5 | const reader = new FileReader() | |
6 | ||
7 | reader.onerror = err => logger.error('Cannot read input file.', err) | |
8 | reader.onloadend = () => res(reader.result as string) | |
9 | reader.readAsDataURL(input) | |
10 | }) | |
11 | } | |
12 | ||
13 | export { | |
14 | imageToDataURL | |
15 | } |