Skip to content

Commit 2403c72

Browse files
committed
data:image/svg+xml as base64
1 parent f263b12 commit 2403c72

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

build/BuildLibary.ps1

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,16 @@ function Convert-SvgToMxLibrary {
3030
Get-ChildItem -Path $InputFolder -Filter *.svg | ForEach-Object {
3131
$file = $_
3232
$svgContent = Get-Content -Path $file.FullName -Raw
33-
$encodedSvg = [System.Uri]::EscapeDataString($svgContent)
34-
$imageUri = "data:image/svg+xml,$encodedSvg"
33+
$bytes = [System.Text.Encoding]::UTF8.GetBytes($svgContent)
34+
$base64 = [Convert]::ToBase64String($bytes)
35+
$image = "data:image/svg+xml,$base64"
3536

3637
$xml = @"
3738
<mxGraphModel>
3839
<root>
3940
<mxCell id="0"/>
4041
<mxCell id="1" parent="0"/>
41-
<mxCell id="2" value="" style="shape=image;verticalLabelPosition=bottom;verticalAlign=top;imageAspect=0;aspect=fixed;image=$imageUri" vertex="1" parent="1">
42+
<mxCell id="2" value="" style="shape=image;verticalLabelPosition=bottom;verticalAlign=top;imageAspect=0;aspect=fixed;image=$image" vertex="1" parent="1">
4243
<mxGeometry width="$GeometryWidth" height="$GeometryHeight" as="geometry"/>
4344
</mxCell>
4445
</root>

0 commit comments

Comments
 (0)