WeBWorK Main Forum

Use GD to modify an existing image?

Use GD to modify an existing image?

by Stephen Corwin -
Number of replies: 2
Hi--

I'd like to use GD to write on a background image. Can anyone tell me how to do that or provide a link to some code?

Thanks,

Steve
In reply to Stephen Corwin

Re: Use GD to modify an existing image?

by Michael Gage -
Take a look at http://webwork.maa.org/pod/pg_TRUNK/lib/WWPlot.html

There is an $graph->im() method that gives you access to the underlying GD object.
In reply to Michael Gage

Re: Use GD to modify an existing image?

by Stephen Corwin -
Thanks, but let me clarify. What I'd like to do is to upload a PNG file, use GD::newFromPng() to make a new GD::Image object from that file, and then call various GD methods to modify the image before displaying it. I think that something like

$w = new WWPlot(342,154);
$image = $w->im()->newFromPng($path_to_png);


would make the object if I knew $path_to_png. Is this right? And what should I use for $path_to_png?

Thanks again,

Steve