GD Library Basics

This information was gathered by taking PC example scripts of functions and trying them with MSNTV together with lots of observation. It is in no way complete; but just a few observations I have made to make it easier for you.
Thanks to Pagemaster101 for the script explanations and "doodling".

Since PHP scripts can not be sourced, when asking for help always include a text file of your code or CCP in E mail...If you send someone your php script to view, they can not source it but they can upload it and have your image. More about uploading later. When uploading the lesson text files make a copy and change the extension from txt to php.

You will get two kinds of error messages...
You will get the regular line error messages...correct it and save and view. The second type of error message will be a pop-up that says the informaton can not be used. This means you've called a function that doesn't exist (or work with webby?). After you correct that error you MUST rename it. It will not function after that pop-up...
Here's a zip file. It has a line counter so you can find the line mentioned in the error message( Be sure you can do cgi scripts at your server)...and it has the php primer...Just upzip in the file you're working in and click on the icons to view. The PHP Primer will give you all the information about the PHP your server uses.

For one line commenting use double forward slashes...//
For multiple line commenting use one slash and an asterisk.../*STUFF HERE*/.....ending with an asterisk and one slash.

In using the GDL; you're building top to bottom and at the same time from the screen outwards towards you.... layer upon layer just as you'd do a pencil drawing.

Start with the basic shape of your object and continue to put shapes on top of shapes with the last layer having the tiny details. Whatever you script first will be your bottom layer....and will also be at the top of the screen.

The wonderful thing is that anything can be added into any layer. Just insert the code for it in the proper place. Even an entire background can be added after the fact.

All colors are allocated in RBG and can also be given a transparency factor; and a gradient factor. Basic color allocations can be found on the chart. They are already coded for your convienience...Just "Find" what you want and CCP one or the entire chart. Colors

All colors are allocated in RBG and can also be given a transparency factor. The transparency numbers go from 0...opaque to 127....transparent. It requires this function: $name = imageColorAllocateAlpha($im, 255, 255, 0, 90);

Adding the Alpha in the function and adding a number between zero and 127 AFTER the three RBG numbers.

You can have the same colors with transparency and without as long as you name them differently in the Allocation...blackT and black...for example.

Just a note here about using transparent colors with transparent back. Those colors would change depending on what background color you put them on. One way to get both would be to draw your shape in white or whatever color, then again on top of it with the transparent color. Giving you the transparent coloring as well as the transparent background.

In order to place the shapes or paint drawn shapes or dingbats, one needs to be able to provide the exact coordinate numbers. To make this easier, I drew a line grid to lay over my image showing the major coordinates. You will find it here to transload: Grid
This zip file has an example

Images may be imported. Once imported they can be drawn on and written on as well as many functions not yet tried. Imported images must be in the same directory as the script.

Regular ttf fonts can be used. They should be in the same directory as the script. A colored shadow can be used with them, for annotation. For dingbats, they can be done in any color or a series of transparent colors laid one on the other, or in black and white and then painted with GD or taken to IM for painting and manipulation after uploading.

There are four numbers for annotation. The first number is the size and this appears to be the standard we all know. The second number is angle; 0 being horizontal, and 90 perpendicular bottom to top, -90 perpendicular top to bottom. The last two numbers are x and y position.
Here's an example zip file with an import image, and a ttf font showing annotation with shadow.

Here's an example zip file with a dingbat font and using the font from above to annotate more than once.

Images may be output as png, jpg,or gif....To turn your php script into any of the three is simple. Enter the URL of your php script into your "mover" or a tranloader and upload it to your webspace. As you do so, change the file extension to match what the script output says.

GD BasicsHome