Forum Moderators: coopster
1) How do I set it up so that users can place it in their signatures, sites, etc where php is disabled? (right now the link is like example.com/file.php?id=1111 and, obviously, that can be blocked in some locations for security concerns). I'd like to be able allow them to link to something like 1111.gif.
2) How can I add an additional image to appear similar to text separate of the background?
<?
$id = $_GET['id'];Header ("Content-type: image/gif");
$img_handle = imageCreateFromGIF("http://www.blah.com/dynamic.gif");
$color = ImageColorAllocate ($img_handle, 255, 255, 255);
$colorr = ImageColorAllocate ($img_handle, 000, 000, 000);
$colorrr = ImageColorAllocate ($img_handle, 003, 078, 163);ImageString ($img_handle, 4, 220, 2, "Item 1", $color);
ImageString ($img_handle, 3, 238, 21, "Item 2", $colorr);
ImageString ($img_handle, 3, 215, 37, "Item 3", $colorr);
if($coffer == 0) {
ImageString ($img_handle, 3, 215, 52, "Item 4", $colorr);
}else{
ImageString ($img_handle, 3, 215, 52, "Item 5", $colorr);
}
ImageString ($img_handle, 3, 215, 68, "Item 6", $colorr);
ImageString ($img_handle, 2, 312, 85, "Item 7", $colorrr);ImagePng ($img_handle);
ImageDestroy ($img_handle);
?>
Re: 1) Two ways to do this. One, you can recreate the image dynamically each time it is requested (conserves disk space, eats CPU). Two, you can write the image to your server's disk space then serve up the static image to users (eats disk space, conserves CPU).
To recreate the image each time, give the user an img tag that directly calls your script:
<img src="http://yourdomain.com/yourscript.php?id=1234" />
It doesn't matter to the user if they have php enabled or disabled -- your server is doing the php work, they're just calling an image file from a different server.
To store the image to your server's disk space, add a second argument to your last imagepng function, like so:
imagepng($img_handle, 'savedimages/'.$id.'.png');
Then your users can call that image with something like:
<img src="http://yourdomain.com/savedimages/1234.png" />
$img_handle2 = imageCreateFromGIF("http://www.blah.com/dynamic2.gif");
imagecopy ( $img_handle, $img_handle2, 0, 0, 0, 0, imagesx($img_handle2), imagesy($img_handle2) );
imagedestroy ( $img_handle2 );
To change where the second image is placed on the first image, just change the first 0, 0 pair. Want it 10 pixels right and down from the top left corner? Use:
imagecopy ( $img_handle, $img_handle2, 10, 10, 0, 0, imagesx($img_handle2), imagesy($img_handle2) );
Edited to fix sidescroll. Arg!