This is going to be most useful and relevant when coupled with a frontend mechanic, allowing the user to select an area of an image; however, I'm including the code here as you may need it. You never know!
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, ImageMagik, installed.
Note
If you're using MAMP on a MAC, chances are that you don't have ImageMagick installed by default. There is a process to installing ImageMagick on MAMP; however, there's a quicker way. There's an installer available from Cactuslab at http://www.cactuslab.com/imagemagick, and it works like a charm. The Installing ImageMagick on MAC...