I have something that I use to create simple buttons. I use the command line
interface version of php to create the buttons offline. However, the
function can also be used on an web application easily.
I am creating the image with fixed height and width, you can change it by
using $i_width and $i_height variables in call to ImageCreate /
ImageRectangle/ImageFtText function.

Change it as you like.  One thing, is the fontfile has to be an absolute
file path.

HTH
-R'twick
------------------------------------
Code -----------------------------------
#!/usr/local/bin/php-cli
<?php
function create_image($string,$name) {
$pointsize = 15;
$fontfile = "/usr/local/fonts/arial.ttf";
$imagefile=$name.".png";

$string_size = ImageFtBbox($pointsize, 0, $fontfile, $string,
array("linespacing" => 1));
$s_width = $string_size[4];
$s_height = $string_size[5];
$i_width = $s_width+2;
$i_height = -1 * $s_height+2;

$im = imagecreate(115, 22);
$white = imagecolorallocate ($im, 255, 255, 255);
$black = imagecolorallocate ($im,   0,0  ,0);
ImageRectangle ( $im, 0,0, 114, 21,$black);

ImageFtText($im, $pointsize, 0, (122 - $s_width)/2 - 1, 22-(22+$s_height)/2,
$black, $fontfile, $string, array("linespacing" => 1));

ImagePNG ($im,$imagefile);
ImageDestroy ($im);
}
if ($argc <3) {

        echo "usage: ". $argv[0]." <text> <filename>\n";
        exit (-1);
}
create_image ($argv[1],$argv[2]);
?>
---------------------------- End
Code ---------------------------------------
----- Original Message -----
From: "Michael Weiner" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Friday, January 03, 2003 11:58 AM
Subject: [PHP] ImageCreateFromPNG


> Does someone have a script of php function or page that has this code
> working that i can review? I am wanting to create a webpage that will
> let a user enter in an image name (i.e. a png or whatever) and have php
> create an image from that...
>
> Thanks in advance
> Michael Weiner
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to