MakieOrg / Makie.jl

Interactive data visualizations and plotting in Julia
https://docs.makie.org/stable
MIT License
2.42k stars 313 forks source link

Save metadata with plots #3167

Closed johnomotani closed 2 months ago

johnomotani commented 1 year ago

Feature description

It can be useful to save some metadata in the file of a saved plot. For example for provenance tracking - if I am making a plot of some simulation data, I might want to save some identifier for the simulation (e.g. a UUID), the time-point used to make the plot, etc.

Cairo has a function for doing this for pdfs: https://www.cairographics.org/manual/cairo-PDF-Surfaces.html#cairo-pdf-surface-set-metadata

It would be great to be able to pass a keyword argument to add metadata, like

save("foo.pdf", fig; pdf_metadata=(author="AB Creator", keywords="run_id:12345,t=42.0"))

It seems like only certain metadata keys are supported (https://www.cairographics.org/manual/cairo-PDF-Surfaces.html#cairo-pdf-metadata-t), and I don't know if it's possible to add metadata to other output formats. I'd expect (and be happy to get!) an error if I ask to add metadata to a format that does not support it, or with a metadata key that is not allowed.

I guess this feature would need cairo_pdf_surface_set_metadata() to be exposed by Cairo.jl, so I'll open an issue there too and link it to this one.

t-bltg commented 1 year ago

I'm also interested in this feature natively supported in Makie.

My current workaround to add metadata (git hash) for .png, .jpg files is to use ExifViewer.jl (xref https://github.com/JuliaImages/ExifViewer.jl/issues/24).

ffreyer commented 2 months ago

Closing this as duplicate of #576