Published
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.
Learn more