2022-07-15 13:30:14 +00:00
|
|
|
import { logger } from './logger'
|
|
|
|
|
2021-09-08 08:10:51 +00:00
|
|
|
function imageToDataURL (input: File | Blob) {
|
|
|
|
return new Promise<string>(res => {
|
|
|
|
const reader = new FileReader()
|
|
|
|
|
2022-07-15 13:30:14 +00:00
|
|
|
reader.onerror = err => logger.error('Cannot read input file.', err)
|
2021-09-08 08:10:51 +00:00
|
|
|
reader.onloadend = () => res(reader.result as string)
|
|
|
|
reader.readAsDataURL(input)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
export {
|
|
|
|
imageToDataURL
|
|
|
|
}
|