Welcome to PlantUML Q&A, where you can ask questions and receive answers from other members of the community.

You can also submit new features request and vote for them.

Embedding images (bitmap or svg) in diagrams

0 votes
Is there a way to embed an image inside a note in activity diagrams? Sometimes I want to associate a small photo to a particular component. Or even use images as the nodes in the activity diagrams.

 

I noticed that URLs were available inside notes. Perhaps those URLS could be turned into embedded images.
asked Sep 6, 2015 in Wanted features by anonymous

2 Answers

+1 vote

Hi,

Using creole engine (see http://plantuml.com/creole.html ), you can have:

start
:foo;
note left
 You can use images
<img:http://plantuml.com/logoc.png>
end note
stop

Is this what you are looking for ?

answered Sep 6, 2015 by plantuml (125,190 points)
edited Sep 6, 2015 by plantuml
Awesome! So this must allow data uris right? And potentially it could be combined with include directives to embed the image into the file as well?
If you are refering to https://en.wikipedia.org/wiki/Data_URI_scheme the answer is not yet.
You are suggesting that the following example should work, right ?

start
:foo;
note left
 You can use images
<img:data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA
AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
9TXL0Y4OHwAAAABJRU5ErkJggg==>
end note
stop

The closest thing which is working today is sprite ( http://plantuml.com/sprite.html ) but this is not exactly what you are looking for.
Would this work with includes? Considering that I may not want to write the base64 inline, but I want the output to have the image embedded?
Yes, it works with includes
+1 vote

In the last beta https://dl.dropboxusercontent.com/u/13064071/plantuml.jar

You can have:

@startuml
start
:foo;
note left
 You can use images <img:data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==>
end note
stop
@enduml

Note that base64 has to be on a single line. We will try to add the hability to have data on several lines.

Thanks for the suggestion!

answered Sep 6, 2015 by plantuml (125,190 points)
How do you specify a scaling or size of the image? Is that doable?
You can specify a scale, like in the following examples:

@startuml
start
:foo;
note left
 You can use images
<img:http://plantuml.com/logoc.png{scale=2}>
end note
stop
@enduml

@startuml
start
:foo;
note left
 You can use images <img:data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=={scale=3}>
end note
stop
@enduml

Is this what you are looking for ?
Thanks this is exactly what I was looking for.

Is there a page that lists all these attributes that can be included? For example I'm also looking to center the image.
Support This Project Offer 250 Mo! Follow PlantUML on Twitter
...