60 lines
2.0 KiB
Plaintext
60 lines
2.0 KiB
Plaintext
#!/usr/local/bin/perl
|
|
# Change above line to path to your perl binary
|
|
##---------------------------------------------------------------------------##
|
|
## Author:
|
|
## Pradeep Padala, ppadala@cise.ufl.edu
|
|
## Description:
|
|
## GD Text Example
|
|
##---------------------------------------------------------------------------##
|
|
## Copyright (C) 2002 Pradeep Padala, ppadala@cise.ufl.edu
|
|
##
|
|
## This program is free software; you can redistribute it and/or modify
|
|
## it under the terms of the GNU General Public License as published by
|
|
## the Free Software Foundation; either version 2 of the License, or
|
|
## (at your option) any later version.
|
|
##
|
|
## This program is distributed in the hope that it will be useful,
|
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
## GNU General Public License for more details.
|
|
##
|
|
## You should have received a copy of the GNU General Public License
|
|
## along with this program; if not, write to the Free Software
|
|
## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
## 02111-1307, USA
|
|
##---------------------------------------------------------------------------##
|
|
|
|
use GD;
|
|
do "init_colors.pl";
|
|
|
|
# Create a new image
|
|
$im = new GD::Image(200, 80);
|
|
|
|
# Allocate some colors
|
|
&InitColors($im);
|
|
|
|
# Make the background transparent and interlaced
|
|
$im->transparent($white);
|
|
$im->interlaced('true');
|
|
|
|
# Create a Border around the image
|
|
$im->rectangle(0, 0, 199, 79, $black);
|
|
$x1 = 2;
|
|
$y1 = 2;
|
|
|
|
# Draw text in small font
|
|
$im->string(gdSmallFont, $x1, $y1, "Small font", $blue);
|
|
$im->string(gdMediumBoldFont, $x1, $y1 + 20, "Medium Bold Font", $green);
|
|
$im->string(gdLargeFont, $x1, $y1 + 40, "Large font", $red);
|
|
$im->string(gdGiantFont, $x1, $y1 + 60, "Giant font", $black);
|
|
|
|
# Open a file for writing
|
|
open(PICTURE, ">picture.png") or die("Cannot open file for writing");
|
|
|
|
# Make sure we are writing to a binary stream
|
|
binmode PICTURE;
|
|
|
|
# Convert the image to PNG and print it to the file PICTURE
|
|
print PICTURE $im->png;
|
|
close PICTURE;
|