[LON-CAPA-dev] perl graphics

Guy Albertelli II lon-capa-dev@mail.lon-capa.org
Sat, 15 Dec 2007 13:52:26 -0800


Hi Peter,

> would it be possible to use a perl graphics package with loncapa?
> Such as GD?
> Is it considered to be a security issue?
Couple of issues here

- We don't allow "use XXX" in the perl script because we don;t want
instructors bloating apache children and have unportable problems (We
want to know what all packages a problem is and could use so that they
won't act weird when a student goes to a different server.)

- we have added packages in the past...

- when it comes to output like this we need to make sure we can print
and display on the web the resulting output. (I don't believe GD has a
PS mode...)


However to address your specific concern creating graphics.

1) lots of users have been successful with using <plot> to draw things

2) there is a <drawimage> tag that is mostly functional (I beleive web
and print work great it is the edit interface that has lagged on it)

drawimage.pm is the soure looking in there and randomlylabel.pm might
explain how things work...

I never advertised this beacause it was undone (edit interface) and it
seemed likely that a better solution was to just support SVG, by rendering
it server side into a static image that got displayed/printed so the
users browser didn't need to support it...

I still think supporting SVG is the better long term solution but for
the short term here is a quick overview of <drawimage> (which you
might note is basically just turing GD into XML)

A rough overview is:

thinckness/width/height/x/y/x1/y1/x2/y2 are in pixels
color is in HTML style hexcodes
filled/transparent take 0/1 (for false/true)
<drawimage width="" height="">
   <text x="" y="" font="" color="" direction="" >Text to draw</text>
   <line x1="" y1="" x2="" y2="" color="" thickness="" />
   <rectangle x1="" y1="" x2="" y2="" color="" thickness="" filled="" />
   <arc x="" y="" width="" height="" start="" end="" color=""
        thickness="" filled="" />
   <fill x="" y="" color="" />
   <polygon color="" filled="" open="" thickness="" >
        <point x="" y="" />
	<point x="" y="" />
   </polygon>
   <image x="" y="" clipx="" clipy="" clipwidth=" clipheight=""
          scaledheight="" scaledwidth="" transparent="">
     # this could be an url, an <img> a gnuplot, or another <drawimage>
   </image>
</drawimage>



> 
> Typing
> use GD;
> in line 2 of a loncapa-perl script
> gives
>  'caller' trapped by operation mask at /usr/lib/perl5/5.8.8/Symbol.pm 
> line 127.
> Compilation failed in require at 
> /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/GD/Image.pm 
> line 6.
> BEGIN failed--compilation aborted at 
> /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/GD/Image.pm 
> line 6.
> Compilation failed in require at 
> /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/GD.pm line 14.
> BEGIN failed--compilation aborted at 
> /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/GD.pm line 14.
> Compilation failed in require at (eval 4328) line 2.
> BEGIN failed--compilation aborted at (eval 4328) line 2.
> 
> We have the need to generate on the fly graphs (graph as in graph theory)
> I have never worked with perl graphics.
> 
> Peter
> 
> -- 
> Peter Riegler
> Fachhochschule Braunschweig/Wolfenb??ttel
> Salzdahlumer Str. 46/48, 38302 Wolfenb??ttel
> Tel. +49 5331 939 6314, Fax. +49 5331 939 6002
> email: p.riegler@fh-wolfenbuettel.de
> http://public.rz.fh-wolfenbuettel.de/~riegler
> _______________________________________________
> LON-CAPA-dev mailing list
> LON-CAPA-dev@mail.lon-capa.org
> http://mail.lon-capa.org/mailman/listinfo/lon-capa-dev

-- 
guy@albertelli.com   0-7-0-6-27,137