- From: Yoav Weiss <notifications@github.com>
- Date: Tue, 22 Sep 2015 08:56:09 -0700
- To: WICG/img-conversion <img-conversion@noreply.github.com>
Received on Tuesday, 22 September 2015 15:56:38 UTC
> </p>
> <pre class='example highlight'>
> -function ImageDataToBlob(imageData)
> -{
> - return imageData.toBlob(); // implied "image/png" format
> -};
> +var type = (Image.canEncodeType("image/jpg")) ? "image/jpg" : "image/png";
> +imageData.toBlob(type).then((blob) => {
> + const img = new Image();
> + img.src = URL.createObjectURL(blob);
> + document.body.appendChild(img);
Appending children to the end of body from async funcs can be... not so great, since you're racing against other scripts adding things to the DOM.
---
Reply to this email directly or view it on GitHub:
https://github.com/WICG/img-conversion/pull/14/files#r40104529
Received on Tuesday, 22 September 2015 15:56:38 UTC