Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Template engine for image generation

Does anyone know of any templating engines for generating images, preferably Java-based?

What I have in mind is something like StringTemplate where a you have a set of parameterized templates that render to an image (or SVG, etc) rather than text. It needs to be more general purpose than "insert text here to generate a sign". Primitives would be various shapes, other images, text, etc.

I realize I can build this pretty easily myself with a text template engine that generates SVG, but I'm looking for something that works "out of the box".

Thanks!

To elaborate a bit, here's some totally made up syntax for what I'm looking for. Image I want to generate an icon with some status overlays (like icons in Eclipse):

iconTemplate(base, status, svn) {
    image($base), // the base icon
    // create a 2x2 grid for status overlays
    gridlayout(2, 2) {
        // conditionally add overlays in corners based on parameters
        if($status == "error") {
            image("error.png") {
                layoutInfo : cell(1, 0)
            }
        }
        if($svn == "changed") {
            image("changed.png") {
                layoutInfo : cell(1, 1)
            }
        }
    }
}

Note this syntax is completed made up and obviously sucks, but maybe it gets the idea across :)

like image 791
Dave Ray Avatar asked Jan 16 '09 14:01

Dave Ray


1 Answers

I'm not sure I understand your needs, but how about creating a JPanel (you can use layouts, labels, other shapes ...) and save it as an image?

Here you can find information about how to save a JPanel as an image.

like image 110
asalamon74 Avatar answered Oct 06 '22 22:10

asalamon74