#!/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";
####
#!/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";
####
[leo@mescaline ~]$ perl test2.pl
panic: malloc at test2.pl line 15.