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

Unit 12: Images



            If you cannot install PHP, “Installing and Configuring PHP,” and are stuck with a version of   Notes
            PHP earlier than 4.3.0, you will have to go to http://www.boutell.com/gd/ and download the
            source of the GD library. Follow the instructions included with that software, and consult its
            manual for difficulties with installation.

            To enable the use of the GD library at installation time, Linux/Unix users must add the following
            to the configure parameters when preparing to build PHP:
            —with-gd

            If you download your own version of GD, you must specify the path, as in
            —with-gd=/path/to/gd.

            After running the PHP configure program again, you must go through the make and make
            install process. Windows users who want to enable GD simply have to activate php_gd2.dll as
            an extension in the php.ini file.
            When using the GD library, you are limited to working with files in GIF format. However, by
            installing additional libraries, you can work with JPEG and PNG files as well.
            12.2.1 Obtaining Additional Libraries

            Working with GIF files might suit your needs perfectly, but if you want to create JPEG or PNG
            files, you will need to download and install a few libraries, and make some modifications to
            your PHP installation.
            JPEG libraries and information can be found at ftp://ftp.uu.net/graphics/jpeg/.

            PNG libraries and information can be found at http://www.libpng.org/pub/png/libpng.html.

            If you are working with PNG files, you should also install the zlib library, found at
            http://www.gzip.org/zlib/.

            Follow the instructions at these sites to install the libraries. After installation, Linux/Unix users
            must again reconfigure and rebuild PHP by first adding the following to the PHP configures
            parameters (assuming that you want to use all three, if not, just add the applicable ones):

            —with-jpeg-dir=[path to jpeg directory]

            —with-png-dir=[path to PNG directory]
            —with-zlib=[path to zlib directory]

            After running the PHP configure program again, you need to go through the make and make
            install process. Your libraries should then be activated and ready for use.

            12.3  Drawing a New Image

            Drawing shapes and lines with PHP is nothing like drawing with image editing program.
            Actually, when drawing with PHP you become the editing program. You use individual PHP
            functions to define colours, draw and fill shapes, re-size and save the image. These functions
            are part of the GD graphics library that was bundled beginning with PHP version 4.3.0.





                                             LOVELY PROFESSIONAL UNIVERSITY                                   201
   201   202   203   204   205   206   207   208   209   210   211