#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 ...
Get Wicked Cool PHP now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.