...if you are not stuck with GD, and can use Image::Magick, here is a sample script that will overlay text of any color or transparency, and/or another image
#!/usr/bin/perl use warnings; use strict; use Image::Magick; #usage: script baseimage overlayimage text my $image = Image::Magick->new; my $oimage = Image::Magick->new; my $rc = $image->Read('1Zen16.jpg'); $rc = $oimage->Read('overlay.png'); my $text = "\nlooking for nirvana\n :-)\n"; $rc = $image->Composite( geometry => '+30+30', compose=>'Atop', image => $oimage, opacity => '100%', tile => 0, ); $image->Annotate(pointsize => 36, fill => '#ffcc00ff', #last 2 digits opacity in hex ff=ma +x text => $text, gravity => 'South' ); $image->Write("$0.png"); exit;
...also see Image and Text Watermarked Letters and
#!/usr/bin/perl -w use strict; use Image::Magick; =comment my $text = 'test'; my $im = new Image::Magick; $im->Read("meteo.jpg"); my $rv = $im->Annotate( text => $text, font => 'C:\\WINDOWS\\Fonts\\Arial.ttf', x => 10, y => 10, ); die("Unable to annotate image: $rv\n") if "$rv"; print "Content-type: image/jpeg\n\n"; binmode STDOUT; print $im->Write('jpeg:-'); =cut my $image = Image::Magick->new; $image->Set(size=>'250x100'); $image->Read('1Zen16.jpg'); my $text = "This is a test"; $image->Annotate( pointsize=>40, text=>$text, stroke => '#C0C0C0', # Increase to make stroke more white fill => '#505050', #or red etc, Decrease to make fill more + black gravity => 'center', x=> -10, # offsets y=> -10 # offsets ); print $image->Write("$0.png");

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku

In reply to Re: Perl GD problem with colors for text by zentara
in thread Perl GD problem with colors for text by natol44

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.