Cant generate image from encoded diagram

0 votes
asked Jul 23, 2024 in Question / help by Caio
Hello,

I want to know why I cant generate image from the encoded text like the samples with have on documentation, such as:

https://www.plantuml.com/plantuml/umla/Syp9J4vLqBLJSCfFib9mB2t9ICqhoKnEBCdCprC8IYqiJIqkuGBAAUW2rJY256DHLLoGdrUS2W00

with "Syp9J4vLqBLJSCfFib9mB2t9ICqhoKnEBCdCprC8IYqiJIqkuGBAAUW2rJY256DHLLoGdrUS2W00" being the actual code, I want to use it in the command line app as, for instance:

java -jar plantuml.jar -decodeurl Syp9J4vLqBLJSCfFib9mB2t9ICqhoKnEBCdCprC8IYqiJIqkuGBAAUW2rJY256DHLLoGdrUS2W00

but it generate duplicate first and last line, and appears to not be possible generate also the corresponding image:

@startuml
@startuml
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
@enduml
@enduml

Thanks in advance!

2 Answers

0 votes
answered Aug 5, 2024 by Martin (9,120 points)
 
Best answer

1) I don't think the -decodeurl option is designed to output a diagram as well - I think it purely converts your encoded text in to plain text.

2) You can pipe the -decodeurl output into a second java command that is using -pipe.  e.g. java -jar plantuml-1.2024.6.jar -decodeurl Syp9J4vLqBLJSCfFib9mB2t9ICqhoKnEBCdCprC8IYqiJIqkuGBAAUW2rJY256DHLLoGdrUS2W00 | java -jar plantuml-1.2024.6.jar -pipe > mypng.png

3) The difference between Syp9J4vLqBLJSCfFib9mB2t9ICqhoKnEBCdCprC8IYqiJIqkuGBAAUW2rJY256DHLLoGdrUS2W00 and SoWkIImgAStDuNBCoKnELT2rKt3AJx9IS2mjoKZDAybCJYp9pCzJ24ejB4qjBk42oYde0jM05MDHLLoGdrUSokMGcfS2D1C0 is that the latter includes the @startuml/@enduml and the former does not - note the online server will add the @startuml/@enduml for you (Try visiting https://www.plantuml.com/plantuml/umla/Syp9J4vLqBLJSCfFib9mB2t9ICqhoKnEBCdCprC8IYqiJIqkuGBAAUW2rJY256DHLLoGdrUS2W00 and compare the browser address bar with the page's 'decode url' bar).

4) The @startuml/@enduml are added in for you by -decodeurl.  But there's a bug that generates it twice.  It doesn't actually matter though - plantuml will remove the extra pair if you use the text hence the -pipe above works fine.  If anyone is interested about the bug - in https://github.com/plantuml/plantuml/blob/master/src/net/sourceforge/plantuml/Run.java procedure processArgs, it does these 6 lines:

if (option.isDecodeurl()) {
error.goOk();
final Transcoder transcoder = TranscoderUtil.getDefaultTranscoder();
System.out.println("@startuml");
System.out.println(transcoder.decode(s));
System.out.println("@enduml");

Where you can see it outputs the @startuml/@enduml.  But I think transcoder.decode adds another pair via https://github.com/plantuml/plantuml/blob/master/src/net/sourceforge/plantuml/code/ArobaseStringCompressor.java procedure "decompress".  (ArobaseStringCompressor is called from https://github.com/plantuml/plantuml/blob/master/src/net/sourceforge/plantuml/code/TranscoderSmart.java zlib object).  But it's just me trying to follow the code manually, I haven't debugged, so I could be in the wrong procs.

0 votes
answered Jul 25, 2024 by The-Lu (89,080 points)

Hello C.,

For this code:

@startuml
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
@enduml

Here is the corresponding encoded form:

SoWkIImgAStDuNBCoKnELT2rKt3AJx9IS2mjoKZDAybCJYp9pCzJ24ejB4qjBk42oYde0jM05MDHLLoGdrUSokMGcfS2D1C0

Dont forget @startuml/@enduml...

Enjoy,
Regards,
Th.

commented Jul 25, 2024 by Caio
My problem is not to figure out what is the decoded or encoded form, the actual problem is from a encoded form,  get the corresponding picture output. But what I am getting is the decoded form with some lines duplicated and no picture from the command line JAR plantUML.
...