nitish24p/react-worker-image

Use the image.decode() api

Closed this issue · 2 comments

image.decode is part of the new spec, which decodes images and returns a promise, see if this can be incorporated into it. Also try to check for browser support. And have a silent fallback / failing mechanism

Does it decode in bit array?

Why did you guys close this?
According to the spec: https://html.spec.whatwg.org/dev/embedded-content.html "Because the decode() method attempts to ensure that the decoded image data is available for at least one frame, it can be combined with the requestAnimationFrame() API. This means it can be used with coding styles or frameworks that ensure that all DOM modifications are batched together as animation frame callbacks"

which should mean, if we change https://github.com/nitish24p/react-worker-image/blob/master/lib/ImageWorker.js#L82 to

image.decode().then(this.onLoad)

it should work (of course we have to check for browser support and if the browser doesn't support it, we go with the onload method)