There are a few different was to do this but probably the easiest is to
save the image to disk. Something like:
[% FILTER null;
USE im = GD.Image(50,50);
# allocate some colors
black = im.colorAllocate(0, 0, 0);
red = im.colorAllocate(255,0, 0);
blue = im.colorAllocate(0, 0, 255);
# Draw a blue oval
im.arc(50,50,95,75,0,360,blue);
# And fill it with red
im.fill(50,50,red);
# Output binary image in PNG format
im.png | redirect('/path/to/image.png');
END;
-%]
<img src="/url/to/image.png">
If the images are reusable, you could put in some logic to check if the
file exists already before regenerating.
dark0s wrote:
> Ok, I excuse me because I'm not expert with template toolkit.
> Where is the source of the following block code?
>
> [% FILTER null;
> USE im = GD.Image(50,50);
> # allocate some colors
> black = im.colorAllocate(0, 0, 0);
> red = im.colorAllocate(255,0, 0);
> blue = im.colorAllocate(0, 0, 255);
> # Draw a blue oval
> im.arc(50,50,95,75,0,360,blue);
> # And fill it with red
> im.fill(50,50,red);
> # Output binary image in PNG format
> im.png | stdout(1);
> END;
> -%]
>
>
>
>
>
> --- Ven 9/4/10, Randy J. Ray <[email protected]> ha scritto:
>
>> Da: Randy J. Ray <[email protected]>
>> Oggetto: Re: [Templates] Template::Plugin::GD usage
>> A: "dark0s" <[email protected]>
>> Cc: [email protected]
>> Data: Venerdì 9 Aprile 2010, 21:50
>> dark0s wrote:
>>> With stdout(1) system outputs a lot of symbols without
>> sense.
>>
>> That's because you're trying to emit the image directly
>> within the table cell. HTML doesn't work like that. You have
>> to reference images with the "<img>" tag and a URL
>> that (when fetched) returns the image data.
>>
>> Randy
>> --
>> """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
>> Randy J. Ray Sunnyvale, CA
>> http://www.rjray.org [email protected]
>>
>> Silicon Valley Scale Modelers: http://www.svsm.org
>>
>
>
>
>
> _______________________________________________
> templates mailing list
> [email protected]
> http://mail.template-toolkit.org/mailman/listinfo/templates
_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates