Skip to content

Commit da6baf0

Browse files
committed
fix loadImage for browsers
- closes #92
1 parent bc8cbed commit da6baf0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/browser.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ const {asBuffer, asDownload, asZipDownload, atScale, options} = require('./io')
99

1010
const _toURL_ = Symbol.for("toDataURL")
1111

12-
const loadImage = src => new Promise((onload, onerror) =>
13-
Object.assign(new Image(), {crossOrigin:'Anonymous', onload, onerror, src})
14-
)
12+
const loadImage = src => {
13+
let img = Object.assign(new Image(), {crossOrigin:'Anonymous', src})
14+
return img.decode().then(() => img)
15+
}
1516

1617
class Canvas{
1718
constructor(width, height){

0 commit comments

Comments
 (0)