Metadata Extract from SVG Not Working

0 votes
asked Apr 20, 2023 in Bug by Ken Campbell (120 points)
reshown Apr 20, 2023 by plantuml

Tested on plantuml-1.2023.6

Since plantuml-1.2023.1 metadata is encoded in SVG files meaning that you now have to use the -metadata command line option to extract the metadata.  However, this does not work.

Issue 1 - Metadata In SVG Not Encoded Correctly

I generated an SVG diagram from the following PlantUML source:

@startuml
Title Test SVG Metadata

!$ODA_tint = 90
!$box_one_color = "#FFFFB5"
!$box_two_color = %hsl_color( 274,  54, 59*$ODA_tint/100+41 )

box "First Box" $box_one_color
participant "One" as a
end box
box "Second Box" $box_two_color
participant "Two" as b
end box

==Test==
a -> b ++: <color:red>test</color>
b -->> a --: test response
@enduml

When you try to using the java -jar plantuml-1.2023.6.jar -metadata <SVG diagram file> command I get the following in stderr and only the title line in in stdout:

java : @startuml
At line:1 char:1
+ java -jar plantuml.jar -metadata "svg metadata extract test.svg" > me ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (@startuml:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
 
legend
The plugin you are using seems to generated a bad URL.
This URL does not look like DEFLATE data.
It looks like your plugin is using HUFFMAN encoding.

This means you have now to add an header ~1 to your data. For example, you have to change:
http://www.plantuml.com/plantuml/png/NOzHIyCm58MVlR_Y61NKMjR9Ygmi0O...
to
http://www.plantuml.com/plantuml/png/~1NOzHIyCm58MVlR_Y61NKMjR9Ygmi0O...

It will work this way
You may contact the PlantUML team at plantuml@gmail.com
But you should also probably contact the plugin authors you are currently using and send them this image

For the record, here is your data:

NOzHIyCm58MVlR_Y61NKMjR9Ygmi0OVC9zd3YgybRGC6IbAImFRplUkaeda8d9pptNjIspGOr2Oc73xV
yM6IxdNIHDUt-xVN9bcN8B4kMBV-r7XdciuFFl2ZkDdnsPRYnqj7FtjtNt6uY7iylwoUW9AlSlquJrqi
Yo9RBV50n334pWRkiFKdWR-Rw6hK8TdEZfgxYBqp0Zf2at4zE7d13wRph7_vkSq_lZxwYMzddgGy_rzA
qiWLMcHPXSt4Li7qAh6vMKnQKOiyLmgSp2kS7GGJH- -YeMy0
endlegend
@enduml

As you can see from the data, there is a space in the encoded string (7th-last character in the string).  In my testing I noticed that a space always occurs between two hyphens in the encoded metadata string in the SVG diagram file, rendering it invalid.  As per the suggestion it is not HUFFMAN encoding.  If I manually remove the space from the encoded metadata string in the SVG file and once again extract the metadata I get the following output in stderr:

java : @startuml
At line:1 char:1
+ java -jar plantuml.jar -metadata "svg metadata extract test.svg" > me ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (@startuml:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

Title Test SVG Metadata

!$ODA_tint = 90
!$box_one_color = "#FFFFB5"
!$box_two_color = %hsl_color( 274,  54, 59*$ODA_tint/100+41 )

box "First Box" $box_one_color
participant "One" as a
end box
box "Second Box" $box_two_color
participant "Two" as b
end box

==Test==
a -> b ++: <color:red>test</color>
b -->> a --: test response
@enduml

This is an improvement.  However, an error still occurs, as reported at the top of the output, and causes this output to come via stderr rather than stdout.

Furthermore, the encoded metadata in the SVG file is:

NOzHIyCm58MVlR_Y61NKMjR9Ygmi0OVC9zd3YgybRGC6IbAImFRplUkaeda8d9pptNjIspGOr2Oc73xVyM6IxdNIHDUt-xVN9bcN8B4kMBV-r7XdciuFFl2ZkDdnsPRYnqj7FtjtNt6uY7iylwoUW9AlSlquJrqiYo9RBV50n334pWRkiFKdWR-Rw6hK8TdEZfgxYBqp0Zf2at4zE7d13wRph7_vkSq_lZxwYMzddgGy_rzAqiWLMcHPXSt4Li7qAh6vMKnQKOiyLmgSp2kS7GGJH- -YeMy0

Whereas, if I encode the PlantUML source via the command line using the -encodeurl command line option I get the following:

NSun2y8m40NWsViLZpYM80wYb2P3mJg9GujxqjvGA4b90lRdcrPnyBR7UnzSDwQ9qN5CQ9ytt3cPmIH3HDOl4CqOSbFxHM3VvAjFj9jDI6C_piObY8TZ0HDXYDs0R3wkvTxd_8N7wxcv_C7kvJTeVv2KMlzGYWoaXaLHbAXwF_bG1XvqocLrsB8c2ocrHbxA4ck3m77sBZAz0G00

These are not the same.

Issue 2 - SVG Metadata Does Not Include the Pre-Processed PlantUML

When I extract the metadata from the PNG diagram file I get both the original PlantUML source and the pre-processed PlantUML

However, the SVG metadata may only contain the original PlantUML source and not the pre-processed PlantUML, which is particularly important if include files are involved.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:

[Antispam2 Feature: please please wait 1 or 2 minutes (this message will disappear) before pressing the button otherwise it will fail](--------)
To avoid this verification in future, please log in or register.
...