1. Ok.. this works for me:
    #!/usr/bin/perl use strict; use Cwd; use Carp; use GD; my $jpeg_quality=90; my $content = `date`; my $out = sprintf "/tmp/out.jpg", time; my $image1 = new GD::Image(200,250); my $red = $image1->colorAllocate(255,0,0); my $white = $image1->colorAllocate(255,255,255); $image1->fill(0,0,$white); $image1->string(gdSmallFont,2,2,$content,$red); open(DATEI ,'>', $out) || die "could not write image: +$!"; binmode DATEI; print DATEI ($image1->jpeg($jpeg_quality)); close(DATEI); warn "saved $out\n";
  2. And this freaks out:
    #!/usr/bin/perl use strict; use Cwd; use Carp; use GD; my $font_arg ='/home/leo/misc/fonts/Suicide.ttf'; my $jpeg_quality=90; my $content = `date`; my $out = sprintf "/tmp/out.jpg", time; -f $font_arg or die; my $font = GD::Font->load($font_arg) or die('cant load font'); # line +15 my $image1 = new GD::Image(200,250); my $red = $image1->colorAllocate(255,0,0); my $white = $image1->colorAllocate(255,255,255); $image1->fill(0,0,$white); # background $image1->string($font,2,2,$content,$red); open(DATEI ,'>', $out) || die "could not write image: +$!"; binmode DATEI; print DATEI ($image1->jpeg($jpeg_quality)); close(DATEI); warn "saved $out\n";
    Output:
    [leo@mescaline ~]$ perl test2.pl panic: malloc at test2.pl line 15.

Anyone? Help?


In reply to Re^2: GD string size by leocharre
in thread GD string size by Anonymous Monk

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.