1 function imageToDataURL (input: File | Blob) {
2 return new Promise<string>(res => {
3 const reader = new FileReader()
5 reader.onerror = err => console.error('Cannot read input file.', err)
6 reader.onloadend = () => res(reader.result as string)
7 reader.readAsDataURL(input)