Dude.. make one scripts like image.cgi which spits out the image and your html.cgi or any html will call it like  <img src="/cgi-bin/image.cgi?yup">

do some testing with the image.cgi first via htp see if it does what you want

here.. i made this script that spits out text to screen.. You just have to tweak where on your server the ttf file is .. etc. This script is not fully complete.. but.. it works!

#!/usr/bin/perl -wT use strict; use Image::Magick; use CGI; my $conf = { font_size => 8, font_name=>'/srv/www/htdocs-devel/lib/kroe0555.ttf', img_type=>'png', }; my $t = new CGI(); my $string = $t->param('string'); $string ||='leocharre'; $$conf{string} = untaint( $string ); # attempt untaint $$conf{img_height} = int($$conf{font_size}*1.33) ; $$conf{img_width} = ( length($$conf{string}) * int($$conf{font_size}*0 +.8) ); my $bgcolor = $t->param('bgcolor'); my $fgcolor = $t->param('fgcolor'); $bgcolor ||='#fff'; $fgcolor ||='#000'; $$conf{bgcolor} = untaint_color($bgcolor); $$conf{fgcolor} = untaint_color($fgcolor); generate_img($conf); show_and_exit($conf); sub show_and_exit { my $conf = shift; # read in image and output to browser print(qq|Content-Type: image/$$conf{img_type}\n\n|); binmode STDOUT; $$conf{img}->Write($$conf{img_type}.':-'); exit; } sub generate_img{ my $conf = shift; $$conf{img} = Image::Magick->new; $$conf{img}->Set(size => $$conf{img_width}."x".$$conf{img_height}) +; $$conf{img}->ReadImage('xc:'.$$conf{bgcolor}); $$conf{img}->Annotate( font=> $$conf{font_name}, pointsize=> $$conf{font_size}, fill=> $$conf{fgcolor}, text=> $$conf{string}, gravity=> 'center' ); } sub untaint { my $string= shift; if ($string=~/^([a-zA-Z0-9 \.\:\[\]\{\}\+\-_]+)$/){ return $1; } die ("don't like some chars here = [$string]"); } sub untaint_color { my $color = shift; if ($color=~/^([\d\w#]{3,7})$/){ return $1; } die ("the heck kind of color is this? [$color]"); }

In reply to Re: Dymanically Generated Images in Website by leocharre
in thread Dymanically Generated Images in Website by debiandude

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.