yuzutech / kroki

Creates diagrams from textual descriptions!
https://kroki.io
MIT License
2.83k stars 211 forks source link

Diagramsnet does not resolve locally pathed images #1730

Open mgzob opened 5 months ago

mgzob commented 5 months ago

Diagrams.net does not appear to handle clipart based images found locally to the diagrams.net docker itself.

image

This only occurs when an object is referenced via a local path: image=img/lib/clip_art/computers/Printer_Commercial_128x128.png

In the lambda icon to the left it is accessed via mxgraph: shape=mxgraph.aws3.lambda_function

The icons are indeed stored in the docker image. They're copied over at this line, and I can validate they are present at: /usr/local/kroki/assets/img/...

They do not appear to be resolving properly however when used in a diagram.

For replication, here is the xml for the above diagram:

<mxGraphModel dx="636" dy="411" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
  <root>
    <mxCell id="0" />
    <mxCell id="1" parent="0" />
    <mxCell id="XUMacOeo--leUqgM2if5-3" value="This one does not" style="image;html=1;image=img/lib/clip_art/computers/Printer_Commercial_128x128.png" vertex="1" parent="1">
      <mxGeometry x="470" y="212" width="80" height="80" as="geometry" />
    </mxCell>
    <mxCell id="XUMacOeo--leUqgM2if5-4" value="This icon works" style="outlineConnect=0;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;shape=mxgraph.aws3.lambda_function;fillColor=#F58534;gradientColor=none;" vertex="1" parent="1">
      <mxGeometry x="350" y="210" width="80" height="82" as="geometry" />
    </mxCell>
  </root>
</mxGraphModel>

This does resolve properly in the diagramsnet web or local application.

ggrossetie commented 4 months ago

Diagrams.net will produce an <image> tag:

<image xmlns="http://www.w3.org/2000/svg" x="120.5" y="1.5" width="80" height="80" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://app.diagrams.net/img/lib/clip_art/computers/Printer_Commercial_128x128.png"/>

As you can see, the base URL is the server URL. In our case, the diagrams.net server is not accessible and we are using a local HTML page to generate the SVG. As a result, the href is:

<image x="120.5" y="1.5" width="80" height="80" xlink:href="file:///path/to/diagrams.net/assets/img/lib/clip_art/computers/Printer_Commercial_128x128.png"/>

I don't want to serve assets from https://kroki.io. The objective has always been to convert text diagrams into self-contained images (i.e., without any connection to kroki.io).

I don't know if diagrams.net supports embedding png/jpeg images into SVG (using data URIs)? If not, you should probably create a feature request. If it does, then we could configure the export to use that mode.