O'Reilly logo

Wicked Cool PHP by Brian Ward, William Steinmetz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

#67: Creating Thumbnail Images

When you allow users to upload images to your site (see "#54: Uploading Images to a Directory" on #54: Uploading Images to a Directory), you often need a small preview image (called a thumbnail) for inclusion on larger pages and image gallery browsing. This section shows you a function called mkthumb() that creates thumbnails with the help of GD. To use the function, you need the following:

  • A PHP-writable directory for writing the thumbnails (if you don't know how to make a directory writable, see "File Permissions" on File Permissions)

  • The GD library

The mkthumb() function takes two parameters: the name of the input image file and the desired name of the thumbnail. You need to independently verify that the image file ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required