[erlang-questions] suggestions for erlang drawing toolkit?

Richard Carlsson carlsson.richard@REDACTED
Tue Aug 9 09:16:59 CEST 2011


On 08/08/2011 09:45 PM, Garry Hodgson wrote:
> for some visualization work i'm doing i need to be able to generate
> images from basic line/ellipse/text kind of primitives. we've been
> using PIL (Python Imaging Library) for this, but it'd be nicer to do
> this in just erlang. ideally i'd like to be able to generate PNG and
> SVG output.

If one of the formats you want is SVG, you presumably don't wan't to 
generate a raster image as the master output. So why not generate SVG 
directly? Using xmerl and the "simple" xml representation, the following 
example:

   <rect width="300" height="100"
style="fill:rgb(0,0,255);stroke-width:1;
stroke:rgb(0,0,0)"/>

becomes:

  [{rect, [{width,"300"},{height,"100"},
  {style,"fill:rgb(0,0,255);stroke-width:1;stroke:rgb(0,0,0)"}],
    [],}]

Then export this via xmerl to an XML file "foo.svg",
and if you want a bitmap, run os:cmd("convert foo.svg foo.png")
where 'convert' is the ImageMagick convert command. Just install the 
imagemagick package if you don' have it already.

    /Richard



More information about the erlang-questions mailing list