Coding Images to change

Do you have access to the server? (i.e is this a home server or are you buying hosting?)...

to check if the GD library is installed create a simple script like this

Code:
<?php
phpinfo();
?>
That page will tell you all the modules that are installed.
 
The problem is that you don't have the GD module installed...


they'll have to add the library (either.so or .dll depending on whether it's Linux/unix or windows).
and they'll have to alter the PHP.ini file to tell it to load the module as well...

I don't thin that this can be done with cpanel access so you'll have to get your hosting provider to do this for you.
 
Okay, I managed to get the GD Libary installed! :D

I got the IP one too work! Now, how do you edit the size and content and such?
How to you make it overlap an exsisting PNG image?

Thanks
Jamie
 
header ("Content-type: image/png");

headers are sent to make sure the broswer knows it's a picture, and not text.

$im = @ImageCreateFromPNG ("php.png");
if(!$im) {

all that line does is check that an image can be created, if you can create an image space then nothing else happens.

$len = 8*(strlen($ip))+6;
$hig = 16;

those lines check the length of the IP address, so a different sized address will generate different numbers, (eg 4.0.0.1 or 217.195.167.105) so a larger box is drawn for a longer text string...

$img_handle = ImageCreate ($len, $hig) or die ("Cannot Create image");
that line actually creates the image where $len is the horizontal length of the image and $hig is the height, so you can change these to be however you want them to to create large or small images.

$back_color = ImageColorAllocate ($img_handle, 0, 0, 0);
The first colour set is the back colour for the image

$txt_color = ImageColorAllocate ($img_handle, 255, 255, 255);

and that sets the forecolour, note that you cab define and use any number of colours that you want.

ImageString ($img_handle, 3, 5, 1, "$ip", $txt_color);
Image string function draws text on a picture


ImagePng ($img_handle); }
and that actually forms the picture from al the information that been stored in the memory space $inmg_handle

?>


You coluld draw on an image by getting rid of the second rceateimage line and just using the first image pointer ($im) which I'd only used as a test...

to be honest you'll find far more help on the PHP site than I can feasibly give you here, just use the function search to look up some of the functions, and you could look at the related functions as well.
 
Okay thank you!

I have a PNG image (made in CS2) and I just want to add text over it in differnt places.
Is this easy to do?

J
 
yes... so long as you know where you want to put the text...

ImageString ($img_handle, 3, 5, 1, "$ip", $txt_color);

draws an picture of the words, the arguments are text size (1-5). xposition, (from left) yposition (from top), the actualy string, and the colour (defined with imagecolorallocate() function.

to position text on a picture, just find where you want to put it, and then enter the co-ordinates of where you'd like it.
 
Back
Top Bottom