note 71822 deleted from function.imagecreatefromjpeg by nlopess
| From: | nlopess@php.net | Date: | Mon, 18 Dec 2006 10:52:38 +0000 |
| Subject: | note 71822 deleted from function.imagecreatefromjpeg by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-120721@lists.php.net to get a copy of this message | ||
Note Submitter: peterolds at peterolds dot info
Reason: useless
----
Going along with the example on the top of the page I added a simple rand() script in to randomly
change and save the image here's what I have:
<?php
$rand = rand(1,3);
if($rand == 1) {
$imgname = "1.jpg";
} else if ($rand == 2) {
$imgname = "2.jpg";
} else {
$imgname = "3.jpg";
}
$im = @imagecreatefromjpeg($imgname); /* Attempt to open */
if (!$im) { /* See if it failed */
$im = imagecreatetruecolor(150, 30); /* Create a black image */
$bgc = imagecolorallocate($im, 255, 255, 255);
$tc = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 150, 30, $bgc);
/* Output an errmsg */
imagestring($im, 1, 5, 5, "Error loading $imgname", $tc);
}
ImageJPEG($im,"4.jpg");
?>
You can see that it creates 4.jpg every time the script is run.
After I did that I set a cron job on my server to run that php script every minute so I can have the
image constantly changing.
An example of this can be found here: www.pwddnet.net/randomsig/another.php
And the Image Created can be found here:
www.pwddnet.net/randomsig/4.jpg
Any questions or comments send to peterolds@peterolds.info