Hi, I am quite new with PHP so please bear with me.
I would like to update old code I have that I use for signatures. Currently it functions like so:
- Pulls one image from a folder at random, the file names are not directly associated with the code so it is possible to put new images without changing the code.
- Is able to display some text that used to be used, but was later disabled.
Problems:
- Current use requires multiple images.
Here is what the old code is like.
What I would like it to do is display multiple images in it (like 5 images), I was thinking I probably have to rewrite the whole thing and draw a canvas and then make the program pull the images and I set the x/y coordinate so it can place it correctly.
If anyone has any suggestions to go about this please reply back. Just to be complete, I would like to retain the ability to randomly pick a image from a folder, the canvas should be 490 pixels x 130 pixels.
Thanks for your time!
I would like to update old code I have that I use for signatures. Currently it functions like so:
- Pulls one image from a folder at random, the file names are not directly associated with the code so it is possible to put new images without changing the code.
- Is able to display some text that used to be used, but was later disabled.
Problems:
- Current use requires multiple images.
Here is what the old code is like.
Code:
<?php
//
// Load all background images from specified path...
//
$images_ary = array();
$handle = @opendir('./images');
while( $file = @readdir($handle) )
{
if( $file <> '.' && $file <> '..' )
{
$tmpary = explode('.', $file);
$extension = strtolower($tmpary[count($tmpary)-1]);
if( in_array($extension, array('gif', 'jpg', 'jpeg', 'png')) )
{
$images_ary[] = $file;
}
}
}
@closedir($handle);
if( count($images_ary) <= 0 )
{
die("Sorry, no images found!");
}
//
// Randomly select an image...
//
$random = time() % count($images_ary);
$image_info = array(
'image' => $images_ary[$random]
);
$image_text_ary = array();
$image_text_ary[] = array(
array(
'x' => 8,
'y' => 6,
'color' => array(50, 100, 180),
'font' => 9,
'text' => ""
)
);
$random = time() % count($image_text_ary);
$image_text = $image_text_ary[$random];
include('./includes/dynamic_gd_image.php');
?>
If anyone has any suggestions to go about this please reply back. Just to be complete, I would like to retain the ability to randomly pick a image from a folder, the canvas should be 490 pixels x 130 pixels.
Thanks for your time!
Comment