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.

Sprite as internal (in-jar resource) images

+1 vote
Now  we can define  external sprites (image from the filesystem) or internal sprites (textual representation).

Would it be possible to add sprites as  embedded resource in the plantuml jar ? If so it would be easier to distribute a self-contained application.

As an example, syntax could be something like

sprite foo1 jar:icons/archimate/business-process-16.png

Regards,

J.-M.
asked Jan 7, 2016 in Wanted features by anonymous

1 Answer

0 votes

Hello,

I see (http://plantuml.com/archimate) that sprite could be read from embedded png file:

sprite $aService jar:archimate/application-service

Is it possible to read them from a external jar file?

Thanks

answered Oct 11, 2016 by Serge Wenger Work (1,860 points)
This is not documented yet, but you can have:
@startuml
sprite foo1 sprite1.png
Alice->Bob : hello <$foo1> there
@enduml

You have to import your sprite one by one.
If needed, we could implement a new command like:

importsprites some_file.zip

That would automatically import all readable images from "some_file.zip" as sprites.
Thanks for the command to load one by one.

With a zip (or a jar), I can create a library for me and my colleagues, but I'm not sure that a automatic load of all images is good for performance and there can be images with the same name in many zip file. It is why  I suggest to be able to load one by one from an archive file (zip, jar or what is better for you).

Thanks for this great project
Ok, with last beta https://dl.dropboxusercontent.com/u/13064071/plantuml.jar

You can have:

@startuml
sprite foo1 some_file.jar~sprite1.png
Alice->Bob : hello <$foo1> there
@enduml

Where ~ delimits the file name (could be zip or jar) and the entry name in the zip/jar file.
This has not been highly tested...
Fantastic. It work as expected.
Very nice job
Thanks
When I print on big paper (A3 or bigger), I use SVG for the quality, but png sprites are pixelated (Openiconic are OK ("svg inside")). It would be nice if we can also have svg sprite like this:

@startuml
sprite foo1 some_file.zip~sprite1.svg
Alice->Bob : hello <$foo1> there
@enduml
Good idea!

Last beta https://dl.dropboxusercontent.com/u/13064071/plantuml.jar support both syntax:

sprite foo1 some_file.zip~sprite1.svg
sprite foo2 sprite2.svg

Tell us if it's not working for you.
Hello,
It is working half: it is OK when I generate the output is svg, but not OK when the output is png.
OpenIconic is working on both png and svg
Ok, here we have a real issue.
Transforming a SVG figure to bitmap is not simple. Luckily, OpenIconic SVG are really simple, so we made a tiny SVG interpretor that transforms those very simple SVG to bitmap when needed. This code will probably not work with your SVG.

So we have several options:

- either we use "batik" library to transform your SVG to PNG if needed
(batik.jar must be present when running PlantUML)

- either you can provide a PNG version of your icon, so that PlantUML uses it in case of bitmap export
(So, in your zip file, you have both .png and .svg sprites)

Which way sounds best to you ?
Hello,
I understand the problem.

For me do nothing and it work only with svg output (png output has not the image).

If I know the output type, I could use the preprocessor to select the right image extension

Thanks for your work.
Support This Project Offer 250 Mo! Follow PlantUML on Twitter
...