aboutsummaryrefslogblamecommitdiffhomepage
path: root/client/src/root-helpers/images.ts
blob: fb229ce6dab2f6b1e91efc52fa9594f32d1348fa (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13












                                                                         
function imageToDataURL (input: File | Blob) {
  return new Promise<string>(res => {
    const reader = new FileReader()

    reader.onerror = err => console.error('Cannot read input file.', err)
    reader.onloadend = () => res(reader.result as string)
    reader.readAsDataURL(input)
  })
}

export {
  imageToDataURL
}