Skip to content Skip to sidebar Skip to footer

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 drawI

Solution 1:

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.

Post a Comment for "Use Web Worker To Getimagedata From A File"