Platform
Resources
Pricing
Sign in
Get started
Sylvain Lesage
Software engineer at Hugging Face. Prototyping here with JS, d3, three.js.
Workspace
Fork
Published
2 collections
By
Sylvain Lesage
Edited
Feb 28, 2020
4 stars
Insert cell
Insert cell
html
`<img src="${
src
}" style="max-width: 300px" />`
Insert cell
Insert cell
Insert cell
afterOnload
=
src
=>
new
Promise
(
(
resolve
,
reject
)
=>
{
const
img
=
new
Image
(
)
;
img
.
onload
=
(
)
=>
resolve
(
img
)
;
img
.
onerror
=
reject
;
img
.
crossOrigin
=
"anonymous"
;
img
.
src
=
src
;
}
)
Insert cell
Insert cell
afterOnload
(
src
)
.
then
(
img
=>
img
.
complete
)
Insert cell
Insert cell
afterOnload
(
src
)
.
then
(
crop
)
Insert cell
Insert cell
afterOnload
(
src
)
.
then
(
img
=>
crop
(
img
)
.
toDataURL
(
)
)
Insert cell
html
`<img src="${
await
afterOnload
(
src
)
.
then
(
img
=>
crop
(
img
)
.
toDataURL
(
)
)
}" style="max-width: 300px" />`
Insert cell
Insert cell
afterDecode
=
src
=>
{
const
img
=
new
Image
(
)
;
img
.
crossOrigin
=
"anonymous"
;
img
.
src
=
src
;
return
img
.
decode
(
)
.
then
(
(
)
=>
img
)
;
}
Insert cell
Insert cell
afterDecode
(
src
)
.
then
(
img
=>
img
.
complete
)
Insert cell
afterDecode
(
src
)
.
then
(
crop
)
Insert cell
afterDecode
(
src
)
.
then
(
img
=>
crop
(
img
)
.
toDataURL
(
)
)
Insert cell
html
`<img src="${
await
afterDecode
(
src
)
.
then
(
img
=>
crop
(
img
)
.
toDataURL
(
)
)
}" style="max-width: 300px" />`
Insert cell
Insert cell
afterDecodeWithoutCORS
=
src
=>
{
const
img
=
new
Image
(
)
;
img
.
src
=
src
;
return
img
.
decode
(
)
.
then
(
(
)
=>
img
)
;
}
Insert cell
Insert cell
afterDecodeWithoutCORS
(
src
)
.
then
(
img
=>
crop
(
img
)
.
toDataURL
(
)
)
Insert cell
html
`<img src="${
await
afterDecodeWithoutCORS
(
src
)
.
then
(
img
=>
crop
(
img
)
.
toDataURL
(
)
)
}" style="max-width: 300px" />`
Insert cell
Insert cell
afterDecodeWithoutCORS
(
src
)
.
then
(
img
=>
img
.
complete
)
Insert cell
afterDecodeWithoutCORS
(
src
)
.
then
(
crop
)
Insert cell
Insert cell
Insert cell
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Fork
View
Export
Listed in...
Network, cache and memoization
Sylvain Lesage
Image
Sylvain Lesage
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
afterOnload
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
afterDecode
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
afterDecodeWithoutCORS
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
src
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
crop
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML