<br><br><div class="gmail_quote">On Fri, Mar 12, 2010 at 12:16 PM, Jonas Sicking <span dir="ltr"><jonas@sicking.cc></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Fri, Mar 12, 2010 at 11:57 AM, David Levin <<a href="mailto:levin@google.com">levin@google.com</a>> wrote:<br>
> On Mon, Feb 22, 2010 at 3:10 PM, Jonas Sicking <jonas@sicking.cc> wrote:<br>
>><br>
>> What is the use case for this? It seems like in most cases you'll want<br>
>> to display something on screen to the user, and so the difference<br>
>> comes down to shipping drawing commands across the pipe, vs. shipping<br>
>> the pixel data.<br>
><br>
> Apologies for not including this at the start. As now mentioned in several<br>
> places in the thread, the simplest use case is resize/rotate of images.<br>
<br>
</div>As Hixie pointed out, resize/rotate images do not seem solved by this<br>
API. In order to resize an image with this API you need to:<br>
<br>
1. Load the image into an <img><br>
2. Copy the image into a <canvas><br>
3. Extract an ImageData from the <canvas><br>
4. Send the ImageData to the worker thread<br>
5. Import the ImageData into the worker thread canvas<br>
6. Resize/rotate the image using the worker thread canvas<br>
7. Extract an ImageData from the worker thread canvas<br>
8. Send the ImageData to the main thread<br>
9. Import the ImageData into a main thread <canvas><br>
<br>
And if you want to send the resized image to the server:<br>
<br>
10. Extract the data in a serialized format from the <canvas><br>
11. Send using XHR.<br>
<br>
Just looking at just the work happening on the main thread it sounds<br>
like just resizing/rotating on the main thread is faster. Not to<br>
mention much less complex.<br>
<br>
I'm not saying that the proposed API is bad. It just doesn't seem to<br>
solve the (seemingly most commonly requested) use case of<br>
rotating/scaling images. So if we want to solve those use cases we<br>
need to either come up with a separate API for that, or extend this<br>
proposal to solve that use case somehow.<br></blockquote><div><br></div><div>If fromBlob and toBlob were on canvas, it gets rid of steps 1-3 and changes step 4 to be send file to worker thread. I simply didn't include fromBlob/toBlob because toBlob was already being discussed in another thread. I thought it best to let that topic get discussed in parallel, but it is part of this whole thing, so I am interested in that happening (and discussing those apis further). </div>
<div><br></div><div>So it looks like this:</div><div><br></div><div>1. Send the File to the worker thread<br>2. Import the File/blob into the worker thread canvas<br>3. Resize/rotate the image using the worker thread canvas (to thumbnail for instance)<br>
4. Extract a blob from the worker thread canvas</div><div><br></div><div>Either </div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><br>5. Send the blob using XHR in the worker.</span><br>
<br></div><div>or</div><div><br></div><div>5. Send the Blob to the main thread<br>6. Import the Blob into a main thread <canvas></div><div>(or both).</div><div><br></div><div>Given the blob support this would be overall a better user experience because the loading of the image is done in the worker as well as the resize to a much smaller size, so the i/o happening on the main thread is much lower overall.</div>
<div><br></div><div>dave</div></div>