pinafore/routes/_utils/decodeImage.js
2018-08-31 16:35:26 -07:00

11 lines
208 B
JavaScript

export function decodeImage (img) {
if (typeof img.decode === 'function') {
return img.decode()
}
return new Promise((resolve, reject) => {
img.onload = resolve
img.onerror = reject
})
}