Can I reference a png from the include path?

0 votes
asked Dec 9, 2019 in Question / help by roxspring (260 points)
I'm trying to create a library for use in-house but we like to use colour icons via the Creole <Img> tag.

Is there a way of referring directly to png images from the include path?

At the moment I'm considering defining base64 encoded data uris for each of them which feels like madness.

1 Answer

+1 vote
answered Dec 9, 2019 by plantuml (295,000 points)
selected Dec 9, 2019 by roxspring
 
Best answer

You can set up the environment variable plantuml.include.path

(see https://forum.plantuml.net/1553/how-to-pass-a-search-path-for-include-files even if this post does not mention <img>)

It works for included files and for <img>.

commented Dec 9, 2019 by roxspring (260 points)

That's not working for me :(

Given a plantuml.include.path pointing to a directory with a Logo.png and the following lib.puml:

!function $LogoFooter()

footer <img Logo.png>

!endfunction

Then my diagram script correctly resolves the lib.puml location but results in a "File not found" error while attempting to resolve Logo.png relative to the script file rather than the lib file:

@startuml

!include lib.puml

$LogoFooter()

@enduml

Am I doing anything obviously wrong?

commented Dec 9, 2019 by roxspring (260 points)
Looks like this does actually work when running a -verbose command line invocation, but fails under -gui mode... Now need to test it under plantuml-server.
commented Dec 9, 2019 by plantuml (295,000 points)

Maybe you should try with something simpler ?

There might be an issue with !include ?

The following example is working for us :

@startuml
alice->bob : hello <img:logo.png> The value of plantuml.include.path is %getenv("plantuml.include.path")
@enduml

Command line:

java -Dplantuml.include.path="d:/test/main"  -jar plantuml.jar test.txt

With logo.png inside d:/test/main folder.

commented Dec 9, 2019 by roxspring (260 points)

Even simplified I get the same results:

@startuml
title Path: %getenv("plantuml.include.path"), Image: <img:Logo.png>
@enduml

When running java -Dplantuml.include.path=/Users/rob/tmp/lib -jar plantuml.jar -verbose test.puml everything is good, but java -Dplantuml.include.path=/Users/rob/tmp/lib -jar plantuml.jar -verbose -gui fails by attempting to load Logo.png from the current directory.

The "Setting current dir:" verbose log appears different between the two runs too:

(1.984 - 128 Mo) 119 Mo - Working on /Users/rob/tmp/test.puml
(2.039 - 128 Mo) 119 Mo - Setting current dir: .
(2.040 - 128 Mo) 119 Mo - Setting current dir: /Users/rob/tmp

vs

(1.976 - 128 Mo) 117 Mo - Showing MainWindow
(2.220 - 128 Mo) 116 Mo - Init done
(2.226 - 128 Mo) 115 Mo - Timer started
(2.383 - 128 Mo) 122 Mo - Setting current dir: .
(2.384 - 128 Mo) 122 Mo - Setting current dir: /Users/rob/tmp/.

I wonder if that extra /. could be throwing things off somewhere??

commented Dec 10, 2019 by plantuml (295,000 points)
It's a bug on our side...

It should be fixed in last beta http://beta.plantuml.net/plantuml.jar

Thanks for your tests !
commented Dec 10, 2019 by roxspring (260 points)
It certainly is! Thanks as ever for the fast turn around!

Can I ask where the fix actually is though? There seem to be codebases at both SourceForge and GitHub but both only seem to contain released versions, neither have commits this month and so neither contain your fix. I can only assume there's a primary source control system somewhere else...
...