W16
Java
Avatar Icon With Freemarker
This week was one of my tasks creation of user avatar icon based on user name initials. Project is based on JVM so I naturally search for Java based library for this task. And I was not successful. There are many solutions from world of node.js or ruby but nothing for Java. Sad.
So, at first I start writing own library generating SVG image with user initials. I was creating services, templates and rest controller for handling icon requests... and it was wrong. Result was complex and requires lot of implementation. Simply it was anything but not designed by KISS.
What was the right solution? Simple freemarker macro generating custom SVG code:
Usage looks like this:
And result of these 6 lines looks perfect:












