Downloadable Cells

Hello all,

We’ve just pushed out an update that makes cells conveniently downloadable from the cell menu — in the style of Mike’s useful Saving SVG notebook.

Here’s a quick example:

  • Data cells should be downloadable as CSV (if CSV-shaped), and in all cases as JSON.
  • SVG cells should be downloadable as SVG or PNG.
  • Canvas cells should be downloadable as PNG.

Please let us know if it works well for your notebooks: if there are any cells that you think you ought to be able to download that you can’t, or conversely that you shouldn’t be able to download but you can. … or if you have any bright ideas for other download types that we should offer.

Cheers!
Jeremy

8 Likes

This is great - thanks! I was importing the download functions into pretty much every notebook.

Can you add some metadata indicating sRGB to the PNG files?

(Are browsers doing any kind of reasonable color management these days, and properly treating unlabeled stuff as sRGB, the way the spec demands? I spent years occasionally harassing them about how they weren’t following their own spec, but at some point gave up and stopped paying attention.)

Although the current state of affairs in canvas-colorspace land is indeed dismal: https://github.com/WICG/canvas-color-space/blob/master/CanvasColorSpaceProposal.md

It appears as though Chrome and Safari both do the right thing, and include the sRGB colorspace metadata in the PNG.

It’s only Firefox that fails to include it.

Ah gotcha. I didn’t look at how this was implemented. Saving out PNGs is a native browser feature? I thought you might be constructing a PNG file yourself in code, in which case indicating sRGB is fairly simple as there’s an explicit flag for it in the format.

Mini update on downloadable cells:

  • When you download an SVG as a PNG, we now do a better job inlining images and CSS styles, so that what you see in your notebook is what you get as an image file.
  • <style> cells are now downloadable as CSS files:

2 Likes