Adding a watermark can be a useful way to tag images with your copyright (just make sure you're the copyright owner). CodeIgniter comes with an easy method to apply a watermark to an image. Watermarks can be either text or an image overlay and can be positioned on an original image at any position you wish. The following is a description of how to add text watermarks.
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.
Ensure that you have this chapters base recipe that is Uploading images with CodeIgniter already copied and ready to go as this recipe uses the code from Uploading...