Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make createImageBitmap support SVG, but not RenderingContexts #972

Closed
wants to merge 1 commit into from
Closed

Make createImageBitmap support SVG, but not RenderingContexts #972

wants to merge 1 commit into from

Conversation

junov
Copy link
Member

@junov junov commented Mar 31, 2016

This change fixes issue #923 by allowing ImageBitmap objects to
be created from SVG source images, as long as the image has an
intrinsic size. If the image does not have an intrinsic size,
we still reject the promise with an InvalidStateError, as before.

This change also removes CanvasRenderingContext2D from
ImageBtimapSource, which was an oversight in PR #790. Since there
is no longer a concept of a standalone context, this is no longer
needed.

<code>ImageData</code> object, a <code>CanvasRenderingContext2D</code> object, or another
<code>ImageBitmap</code> object, and returns a promise that is resolved when a new
<code>ImageBitmap</code> is created.</p>
<p>Takes <var>image</var>, which can be an <code>img</code> element, a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add <span>SVG <code>image</code></span> element here while you're at it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(markup typo in your comment?)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@annevk
Copy link
Member

annevk commented Apr 1, 2016

LGTM with that nit.

This change fixes issue #923 by allowing ImageBitmap objects to
be created from SVG source images, as long as the image has an
intrinsic size. If the image does not have an intrinsic size,
we still reject the promise with an InvalidStateError, as before.

This change also removes CanvasRenderingContext2D from
ImageBtimapSource, which was an oversight in PR #790. Since there
is no longer a concept of a standalone context, this is no longer
needed.
@junov
Copy link
Member Author

junov commented Apr 1, 2016

New commit with nit addressed.

@annevk
Copy link
Member

annevk commented Apr 1, 2016

Landed as 43ad288.

@annevk annevk closed this Apr 1, 2016
@annevk
Copy link
Member

annevk commented Apr 1, 2016

Thank you!

@sebinsua
Copy link

This monkey patch by @Kaiido implies that "SVG image in Blob as source" isn't supported in Chrome yet and this appears to be the case with my own testing.

Am I misunderstanding things?

Is this tracked as a bug somewhere? It's been 8 years since this was merged.

@Kaiido
Copy link
Member

Kaiido commented Feb 15, 2024

Yes, no browser supports it currently, and I believe that at least in Worker scope it's admitted that we'll never have it because that would mean to move the DOM there.
Might be worth removing it from the specs entirely indeed.

For the ones that really want a bitmap version of an svg Blob, it's still possible through the blob: URL + <img> route, even if that's a bit convoluted:

if (blob.type === "image/svg+xml") {
  const img = new Image();
  img.src = URL.createObjectURL(blob);
  await img.decode();
  URL.revokeObjectURL(img.src);
  return createImageBitmap(img);
}

Kaiido added a commit to Kaiido/html that referenced this pull request Mar 2, 2024
This got added in whatwg#972 but never has been implemented since then.
Supporting SVG in Workers is a no-go for most implementers as this would mean at least some DOM would need to be available in these contexts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants