Open bartbutenaers opened 5 years ago
Bart, brainstorming here without thinking of the memory footprint just yet. Could you define an endpoint on Node-RED where (temporary) images are made available, or even converted from a base64 incoming message? Then that URL to be put in the image source.
Is Inkscape something you would consider easy? This is how some of the other home automation groups generate SVGs.
Or were you trying to keep it local with a web interface? Maybe something like this could be run local: https://editor.method.ac/
Hi @QuagmireMan,
Thanks for your feedback! Have read that openhab article of couple of weeks ago, and that was for me indeed an indication that the svg-based node was a good way to design my floorplans in Node-RED.
But could it be that your feedback is more related to this issue? I will answer you there, to keep things separated... Bart
@Steve-Mcl , I think this issue has become worse due to our third party editor(s) integration: In our demos we use a public available background image. But suppose I have created a background image of my house, which I don't want to publish to the whole world. How can I refer to a private image in my SVG editor and script editor?
About the latter option:
<img alt="" src="data:image/jpeg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDo...">
<svg ...>
<image xlink:href="data:image/jpeg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDo..."/>
</svg>
But not sure how this works:
When the user adds a local image using the DrawSVG online editor:
Then we see that this image also has been inserted by DrawSVG into the SVG as base64 string:
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1130px" height="660px" viewBox="0 0 1130 660" preserveAspectRatio="xMidYMid meet" >
<rect id="svgEditorBackground" x="0" y="0" width="1130" height="660" style="fill: none; stroke: none;"/>
<image x="216" y="128" width="362" height="334.287" id="e1_image" preserveAspectRatio="xMidYMid meet" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAnMAAAJDCAIAAADvqAX..." style="stroke:black;stroke-width:1px;fill:rosybrown;"/>
</svg>
From this I conclude that we should do something similar: When a local file is being added manually to the SVG source xlink:href="file:///some_local_file_path"
), then we should load it automatically into a base64 string (before we load it into the external drawing editor).
Remark: when returning back from the external SVG editor, the original local path should be restored somehow (since we don't want to store the base64 string into Node-RED's flow.json file).
Remark: when returning back from the external SVG editor, the original local path should be restored somehow (since we don't want to store the base64 string into Node-RED's flow.json file).
Hi Bart, this is certainly possible (can easily temporarily store the path in a custom attribute) however when the SVG is served in dashboard, the image file:// may not be accessible in the browser (certainly not on a remote browser)
Options I can think of are (ranked from easiest to hardest)...
Hopefully this feedback gives you a :bulb: moment
Hey Steve, I have also been thinking about an extra 'images' tabsheet, but not sure if that can help us. Users can specify a path to an image (which can be available local or online) both in DrawSvg and manually in the 'Source' tab of our node, and the dashboard needs to be able to access the image.
I think the following situations are possible:
Caution: if the dashboard has no internet access, the image cannot be displayed. So we could convert the hyperlink to a base64 string, before sending the SVG to the dashboard. But of course that is only possible when the Node-RED flow can access the internet ... Don't think there is a waterproof solution and it is best to put on the readme page that local images should be used in these kind of situations.
file:///...
) to a local image in his SVG source tabsheet.This can be solved by doing it another way:
file:///...
) to a local image in his SVG source tabsheet.We will only need an endpoint to get the base64 string of a specified local image file ...
When using an SVG 'image' element, a source image needs to be specified.
For example:
Would like to have an easy way to make local images available. But how? And should it be possible to push the images (as a base64 string) via an input message?