DevDevDev
DevDevDev

Reputation: 5177

Use Web Worker to getImageData from a file

Is it possible to decode the image data from a file in a Web Worker so that I can pass it to the main thread and use putImageData. This is presumably faster than just calling drawImage.

Upvotes: 1

Views: 1408

Answers (1)

Daniel Baulig
Daniel Baulig

Reputation: 10989

Yes it is. The WebWorker API specification allows you to simply postMessage ImageData and ArrayViews to and from it. However, not all implementations currently have this enabled afaik. You may want to have a look at this video from JSConf'11 that also touches this topic.

That beeing said, putImageData is much slower than drawImage, at least when I tested them earlier this year. See this stackoverflow answer for details, especially this jsPerf testcase comparing putImageData, getImageData, toDataURL and drawImage.

Upvotes: 1

Related Questions