web 2.0

How to use PHP & Write Text in image

How to use PHP & Write Text in image The guideline/example scripts how to using PHP and GD library write text in image/picture.

ShotDev Focus:
- PHP & GD Library (Write Text in Image/Picture)

Example 1 (Open picture and write text)


<?
echo "<img src=MyResize/mygirl.png>";
$string = "Narak Girl By ShotDev.Com"; // String
$im = ImageCreateFromJpeg("mygirl.jpg"); // Path Images
$color = ImageColorAllocate($im, 255, 0, 0); // Text Color
$pxX = (Imagesx($im) - 6.5 * strlen($string))/2; // X
$pxY = Imagesy($im)- 20; // Y
ImageString($im, 200, $pxX, $pxY, $string, $color);
imagePng($im,"MyResize/mygirl.png");
ImageDestroy($im);
?>

PHP & GD (Write Text in Image)

Example 2 (Using Font)


<?
echo "<img src=MyResize/mygirl.png>";
$font = 'ANGSAZ.TTF';
$string = "Narak Girl By ShotDev.Com"; // String
$im = ImageCreateFromJpeg("mygirl.jpg"); // Path Images
$color = ImageColorAllocate($im, 255, 0, 0); // Text Color
$pxX = (Imagesx($im) - 4 * strlen($string))/2; // X
$pxY = Imagesy($im)- 10; // Y
ImagettfText($im, 20, 0, $pxX, $pxY, $color, $font, $string);
imagePng($im,"MyResize/mygirl.png");
ImageDestroy($im);
?>

PHP & GD (Write Text in Image)

Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 1.00 out of 10)
Loading ... Loading ...

One Response to “How to use PHP & Write Text in image”

  1. 2dionysius…

Leave a Reply

You must be logged in to post a comment.