#!/usr/bin/perl -w use strict; use Imager; use Imager::Font; use Imager::Color; my $font_file='path/to/font.ttf'; my $text="Foo Bar!"; # create image my $img=Imager->new(xsize=>200,ysize=>50); # set colors my $white=Imager::Color->new("#ffffff"); my $black=Imager::Color->new("#000000"); # change background to white $img->box(color=>$white,filled=>1); # create font object my $ttfont=Imager::Font->new ( type=>'ft2', file=>$font_file, color=>$black, size=>16, ); # draw text $img->string(font=>$ttfont,text=>$text, x=>5,y=>22,aa=>1); # write file $img->write(file=>"image.png") or die "Cannot write $imgfn: ", $img->errstr;