Obviously having the functionality to generate thumbnails is a useful thing to do. Most web developers have had the requirement to create thumbnails of images they are currently uploading, or images previously uploaded, from time to time. Usually that processing would have been done directly with PHP or whichever programming language you may have been using; but CodeIgniter gives you the ability to create thumbnails easily, and this is how you do it.
We're going to use a library of our own for this. If you haven't already done so (in the other recipes in this chapter), create the following file:
/path/to/codeigniter/application/libraries/image_manip.php
Ensure that the
Image_manip
library class is defined as follows:<?php if (! defined('BASEPATH')) exit('No direct script access allowed'); class Image_manip { }
Also ensure that you have the image library, GD2, installed and that you have this chapter's "base" recipe—that is Uploading images with...