WireViz icon indicating copy to clipboard operation
WireViz copied to clipboard

[feature] Enable base64-encoded images in the YAML input

Open kvid opened this issue 2 years ago • 1 comments

Two possible ways to obtain this:

  • Allow image.src to be a base64-encoded image prefixed with e.g. "data:image/png;base64, " as an optional alternative to a filename - similar to what is allowed in HTML, as described in https://github.com/wireviz/WireViz/pull/189#issuecomment-720104657. This option is simple and doesn't change any input YAML syntax. Inheritance might be used for space efficiency when the same image is used several places in the harness.
  • Allow an optional top level images section containing a dict with image filenames as keys and base64-encoded images as values (the prefix mentioned above is probably also needed here to specify image format). ~~This option is more space efficient when the same image is used several places in the harness.~~ This option might also enable overriding the file system when needed.
  • Edit: A variation of the latter alternative above, is an optional top level attachments section to also enable embedding other files than images, e.g. HTML template files or some other external files we might support in the future.

A functionality like this might help in use cases where separate image files can cause problems, like in #233 and #320.

kvid avatar Jul 18 '23 13:07 kvid

It's described in #189 that Graphviz doesn't support base64-encoded images, so we probably would need to decode them into temporary image files in the preparation phase. That will also be good for the aspect_ratio() function.

kvid avatar Jul 18 '23 14:07 kvid