bradcathey has asked for the wisdom of the Perl Monks concerning the following question:
Fellow Monasterians,
I can draw primitives (boxes, lines, circles) with Imager without problems. But I'm trying to get text to work. All I get is a blank screen. I have it feeling it's a font issue: I'm using the wrong path, the wrong type, or. . . .
I have uploaded Copperplate.dfont (Mac) right into my cgi-bin folder. I would like to try something like Arial.ttf, but they are all 0 bytes on my machine.
So, what am I not getting here? Thanks in advance!
#!/usr/local/bin/perl use warnings; use strict; use CGI::Carp qw(fatalsToBrowser); use Imager; my $img = Imager->new(xsize=>400,ysize=>300); $img->box(filled=>1, color=>"ffffff"); #fill the background color my $font = Imager::Font->new( file => 'Copperplate.dfont', index => 0, color => '444444', size => 30, aa => 1); $img->string( font=>$font, text=>'This is a test string', x=>20, y=>10); $img->write(file=>"drawing.jpg", type=>"jpeg") or die "Cannot write f +ile: ", Imager->errstr;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to use Imager for text
by teabag (Pilgrim) on Oct 28, 2005 at 16:40 UTC | |
by bradcathey (Prior) on Oct 28, 2005 at 18:13 UTC | |
|
Re: How to use Imager for text
by zentara (Cardinal) on Oct 28, 2005 at 19:14 UTC | |
by bradcathey (Prior) on Oct 28, 2005 at 22:03 UTC | |
by zentara (Cardinal) on Oct 29, 2005 at 11:14 UTC | |
by bradcathey (Prior) on Oct 29, 2005 at 13:58 UTC | |
by tonyc (Hermit) on Oct 30, 2005 at 23:44 UTC |