Image with data URI containing SVG does not render

0 votes
asked Dec 11, 2020 in Bug by Peter

When I use image in a description that has SVG image encoded in data URI, PlantUML renders "(cannot decode)" instead of the image:

  • using PNG in data URI works: <img:data:image/png;base64,...>
  • using SVG in external file works: <img:file.svg> (PlantUML Web Server - view as SVG)
  • using SVG in data URI does not work: <img:data:image/svg+xml;base64,...> (view as SVG)

The data URI is encoded correctly and is displayed correctly when using in web browser. The SVG content is same as in the case with external file, so PlantUML should be able to render it correctly.

Could you please look into this?

Example:

@startuml
rectangle "<img:data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+DQo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9InNoYXBlcyIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiDQoJIHdpZHRoPSIzMDkuMjg2cHgiIGhlaWdodD0iMjk1cHgiIHZpZXdCb3g9IjAgMCAzMDkuMjg2IDI5NSIgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAwIDAgMzA5LjI4NiAyOTUiIHhtbDpzcGFjZT0icHJlc2VydmUiPg0KDQo8ZGVmcz4NCiAgPHN0eWxlIHR5cGU9InRleHQvY3NzIj4NCiAgDQogICBAbWVkaWEgc2NyZWVuIGFuZCAobWluLXdpZHRoOjUwMHB4KSB7DQoJCSNzdGFyIHsNCgkJCXN0cm9rZS13aWR0aDogMTBweDsNCgkJCXN0cm9rZTogI2U1ZmYxZjsNCgkJCWZpbGw6ICMwMDA7DQoJCQlmaWxsLW9wYWNpdHk6IC45Ow0KCQkJdHJhbnNpdG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CTE1Mi40MjksNS41NTYgMTk3Ljc4OCw5Ny41NTIgMjk5LjI4NiwxMTIuMzQgMjI1LjgxLDE4My45MDcgIi8+DQo8L3N2Zz4NCg==>"
@enduml

1 Answer

0 votes
answered Dec 11, 2020 by plantuml (244,920 points)
 
Best answer
Thanks for the feedback !

This is fixed in last beta http://beta.plantuml.net/plantuml.jar

Tell us if you find other issue.

PS: Your SVG file is really nice :-)
commented Dec 12, 2020 by Peter
Wow, what can I say - awesome!

I verified it works with beta, which makes my tool work without extra step of generating separate files in temporary directory.

Thanks!
commented Jan 26 by Martin
I am sorry to bother you, but I cannot get any SVG images to display. Neither as sprites, nor as <img ...> inlines. Neither as files nor as data URIs. If I substitute a PNG, things work just fine each time. I tried various SVGs, like https://commons.wikimedia.org/wiki/File:Test.svg, but never got any to render.

So, as an experiment, I tried to render the above example, but this also gives me a blank rectangle: in effect, it recognizes the size of the element but does not render it. If I render with -tsvg I can see the outline of a star, but when rendering to PNG, only a large-ish yellow rectangle appears.

I have tried with the current beta version of plantuml.jar (1.2021.01beta5), with the current stable version (1.2021.0) and with older versions (like 1.2020.24). I ran it on OpenJDK version 11.0.9.1, 2020-11-04, as well as  15.0.2, 2021-01-19. I use dotviz 2.44.1, but allways get the same result. I use -verbose, but get no stack traces or similar hints.

I tried pasting the above example into the demo server at www.plantuml.com, which will not accept it.

I am not sure what I am doing wrong. Help!
...