help problemes cgi and GD::Text

J

john.swilting

How to use GD::Text
The documentation says

my $gd_text = GD::Text->new(
text => 'Some text',
font => 'funny.ttf',
ptsize => 14,
);

And I have

#!/usr/bin/perl -w

use strict;
use diagnostics;
use GD;
##use GD::Text;
use CGI;
use CGI::Carp;

my $q = new CGI;

# create a new

my $im = new GD::Image(100,100);

# allocate some colors
my $white = $im->colorAllocate(255,255,255);
my $black = $im->colorAllocate(0,0,0);
my $red = $im->colorAllocate(255,0,0);
my $blue = $im->colorAllocate(0,0,255);

# make the background tra $im_pngnsparent and interlaced
$im->transparent($white);
$im->interlaced('true');

# put a black frame around the picture
$im->rectangle(0,0,99,99,$black);

# draw a blue oval
$im->arc(50,50,95,75,0,360,$blue);

# and fill it with red
$im->fill(50,50,$red);

print $q->header( -type => "image/png", -expires => "-1d");
binmode STDOUT;
print $im->png


How to make
So that both work together
 
J

john.swilting

john.swilting said:
How to use GD::Text
The documentation says

my $gd_text = GD::Text->new(
text => 'Some text',
font => 'funny.ttf',
ptsize => 14,
);

And I have

#!/usr/bin/perl -w

use strict;
use diagnostics;
use GD;
##use GD::Text;
use CGI;
use CGI::Carp;

my $q = new CGI;

# create a new

my $im = new GD::Image(100,100);

# allocate some colors
my $white = $im->colorAllocate(255,255,255);
my $black = $im->colorAllocate(0,0,0);
my $red = $im->colorAllocate(255,0,0);
my $blue = $im->colorAllocate(0,0,255);

# make the background tra $im_pngnsparent and interlaced
$im->transparent($white);
$im->interlaced('true');

# put a black frame around the picture
$im->rectangle(0,0,99,99,$black);

# draw a blue oval
$im->arc(50,50,95,75,0,360,$blue);

# and fill it with red
$im->fill(50,50,$red);

print $q->header( -type => "image/png", -expires => "-1d");
binmode STDOUT;
print $im->png


How to make
So that both work together
I am going to go to bed
I return within 24 hours
I do not indeed have to look in for the doc I believe
 
S

Simon Andrews

john.swilting said:
How to use GD::Text

The documentation says

my $gd_text = GD::Text->new(
text => 'Some text',
font => 'funny.ttf',
ptsize => 14,
);
And I have


# create a new

my $im = new GD::Image(100,100);
[snip]

print $q->header( -type => "image/png", -expires => "-1d");
binmode STDOUT;
print $im->png

How to make
So that both work together

I have to say that looking at the POD for GD::Text it's not at all
obvious! However if you look in the demos directory of the GD::Text
module there is a nice example of how to do it

http://search.cpan.org/src/MVERB/GDTextUtil-0.86/demo/GDWrap.pl

Basically

my $gd = GD::Image->new(400,240);

my $wp = GD::Text::Wrap->new($gd,
width => 180,
line_space => 4,
color => $black,
text => $text,
);

$gd->rectangle($wp->get_bounds(10,10), $blue);
$wp->draw(10,10);

binmode STDOUT ;
print STDOUT $gd->png();
 
J

john.swilting

Simon said:
john.swilting said:
How to use GD::Text

The documentation says

my $gd_text = GD::Text->new(
text => 'Some text',
font => 'funny.ttf',
ptsize => 14,
);
And I have


# create a new

my $im = new GD::Image(100,100);
[snip]

print $q->header( -type => "image/png", -expires => "-1d");
binmode STDOUT;
print $im->png

How to make
So that both work together

I have to say that looking at the POD for GD::Text it's not at all
obvious! However if you look in the demos directory of the GD::Text
module there is a nice example of how to do it

http://search.cpan.org/src/MVERB/GDTextUtil-0.86/demo/GDWrap.pl

Basically

my $gd = GD::Image->new(400,240);

my $wp = GD::Text::Wrap->new($gd,
width => 180,
line_space => 4,
color => $black,
text => $text,
);

$gd->rectangle($wp->get_bounds(10,10), $blue);
$wp->draw(10,10);

binmode STDOUT ;
print STDOUT $gd->png();
Thank you

I have to look not at everything
At first
 
J

john.swilting

Simon said:
john.swilting said:
How to use GD::Text

The documentation says

my $gd_text = GD::Text->new(
text => 'Some text',
font => 'funny.ttf',
ptsize => 14,
);
And I have


# create a new

my $im = new GD::Image(100,100);
[snip]

print $q->header( -type => "image/png", -expires => "-1d");
binmode STDOUT;
print $im->png

How to make
So that both work together

I have to say that looking at the POD for GD::Text it's not at all
obvious! However if you look in the demos directory of the GD::Text
module there is a nice example of how to do it

http://search.cpan.org/src/MVERB/GDTextUtil-0.86/demo/GDWrap.pl

Basically

my $gd = GD::Image->new(400,240);

my $wp = GD::Text::Wrap->new($gd,
width => 180,
line_space => 4,t
color => $black,
text => $text,
);

$gd->rectangle($wp->get_bounds(10,10), $blue);
$wp->draw(10,10);

binmode STDOUT ;
print STDOUT $gd->png();

its ok
that code compil nice
I am going to look a doc To continue
#!/usr/bin/perl -w

use strict;
use diagnostics;
use GD;
use GD::Text;
use GD::Text::Wrap;
use CGI;
use CGI::Carp;

my $q = new CGI;


# create a new

my $im = new GD::Image(100,100);

# allocate some colors
my $white = $im->colorAllocate(255,255,255);
my $black = $im->colorAllocate(0,0,0);
my $red = $im->colorAllocate(255,0,0);
my $blue = $im->colorAllocate(0,0,255);

# make the background tra $im_pngnsparent and interlaced
$im->transparent($white);
$im->interlaced('true');

# put a black frame around the picture
$im->rectangle(0,0,99,99,$black);

# draw a blue oval
$im->arc(50,50,95,75,0,360,$blue);

# and fill it with red
$im->fill(50,50,$red);


my $text = "ok";

my $wp = GD::Text::Wrap->new ( $im,
width => 180,
line_space => 4,
color => $black,
text => $text,
);
$im->rectangle ( $wp->get_bounds(10,10), $blue);
$wp->draw(10,10);

print $q->header( -type => "image/png", -expires => "-1d");
binmode STDOUT;
print STDOUT $im->png
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top