aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/root-helpers/images.ts
blob: c4b09ec3cfcdd9b83e97f406ecdf8d03a0ac784f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { logger } from './logger'

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

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

export {
  imageToDataURL
}