GENERATING THUMBNAIL IMAGES If you can t find this section, it means that the GD extension isn t enabled, so you won t be able to use any of the scripts in this chapter. Your next move depends on your situation. On a hosting company s shared server, there s nothing you can do about it, apart from complain or move to a different host. If you re checking your local testing environment on a Windows computer, open php.ini and locate the following line in the list of Windows extensions: ;extension=php_gd2.dll Remove the semicolon at the start of the line, save php.ini, and restart Apache or IIS. If you still can t see that GD support has been enabled, refer back to Chapter 2. Make sure that the correct version of php.ini is being read, extension_dir is pointing to the correct location, and your Windows path setting includes your PHP folder. On a Mac, GD is enabled by default in the package created by Marc Liyanage that I recommended in Chapter 2. Assuming that GD support is enabled on your server, check the version and the settings for GIF Read Support, GIF Create Support, JPG Support, and PNG Support. GD Version needs to be a minimum of 2. All versions should support JPEG and PNG files, but you need 2.0.28 or later for full GIF support. If the version number is lower than 2.0.28, you will probably be able to read GIF files, but not create them. The scripts in this chapter have been designed to respond appropriately to different levels of support. Strictly for abbreviation/acronym freaks: GIF stands for Graphics Interchange Format, JPEG is the standard created by the Joint Photographic Experts Group, and PNG is short for Portable Network Graphics. Although JPEG is the correct name for the standard, the E is frequently dropped, particularly when used as a filename extension. 8 Manipulating images dynamically The GD extension allows you to generate images entirely from scratch or work with existing images. Either way, the underlying process always follows four basic steps: 1. Create a resource for the image in the server s memory while it s being processed. 2. Process the image. 3. Display and/or save the image. 4. Remove the image resource from the server s memory. This process means that you are always working on an image in memory only and not on the original. Unless you save the image to disk before the script terminates, any changes are discarded. Working with images requires a lot of memory, so it s vital to destroy the image resource as soon as it s no longer needed. If a script runs very slowly or crashes, it probably indicates that the original image is too large. 213
From our experience, we are can tell you that you can find a reliable and cheap webhost service at Java Web Hosting services.