note 102740 deleted from image.examples-png by danbrown
| From: | danbrown@php.net | Date: | Thu, 03 Mar 2011 02:51:30 +0000 |
| Subject: | note 102740 deleted from image.examples-png by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-177518@lists.php.net to get a copy of this message | ||
Note Submitter: John D
----
The current example fails unless the "button1.png" file is located.
I modified the example to account for this:
<?php
if (file_exists("images/button1.png")){
header("Content-type: image/png");
$string = $_GET['text'];
$im = imagecreatefrompng("images/button1.png");
$orange = imagecolorallocate($im, 220, 210, 60);
$px = (imagesx($im) - 7.5 * strlen($string)) / 2;
imagestring ($im, 3, $px, 9, $string, $orange);
imagepng($im);
imagedestroy($im);
} else {
print ("File not fount, exiting...");
}
?>