Page 209 - Open Soource Technologies 304.indd
P. 209

Open Source Technologies



                   Notes              does not mean that it exists on your server. If you have fonts that you created yourself,
                                      you may want to upload those to your web directory and use those instead. At least, that
                                      way, you have a guarantee that the font needed by your script exists.
                                    •  The path setting to the font file is tricky, and depends on the version of the GD library
                                      your web server is using. One way around it is to specify the full path to the file on your
                                      server.

                                 12.4.2 Drawing to Your Image

                                 Besides the line drawing function used above, PHP has other functions that you can use. To
                                 whet your appetite, functions include those that allow you to draw ellipses, arcs and polygons,
                                 change the style of your lines (to say dashed lines), and so on.

                                 However, unless you have special reasons why you might want to dynamically draw complex
                                 pictures onto an image, you should consider creating your base image using a normal picture
                                 editor, load that image using a function like imagecreatefrompng(), and then only modifying
                                 small details with your script. Generating everything from scratch is unnecessary for most
                                 purposes, and can drain your web server resources.

                                 12.5  Image Creation from User Input


                                 You understood that having created an image with php it was possible to load it using the img
                                 tag and it certainly works where the comment is hard coded.

                                 HTML Code:

                                 <html>

                                 <head>
                                 <title>myscripthtml</title>

                                 <script type=”text/javascript”>
                                         function getComments()

                                         {

                                                return true;
                                         }

                                 </script>
                                 </head>

                                 <body>

                                 Provide comments
                                 <form name=”cmt” action=”myscript2.php”  method=”GET” onSubmit=”return
                                 getComments()”/>
                                 <input type=”text” name=”cmment”/>

                                 <input type=”submit” value=”submit comments”/>
                                 </form>

        204                               LOVELY PROFESSIONAL UNIVERSITY
   204   205   206   207   208   209   210   211   212   213   214