How to Create Thumbnail with CodeIgnitor

Uploading images is a common task in almost every websites. Only displaying the original images will make the site load slower. That’s why we need to create a thumbnail for each image and show it by default.

CodeIgnitor provides a built-in class called Image Manipulation to make creating thumbnail easy to complete.

Image Manipulation class allows you to perform the following actions:

  • Resizing
  • Thumbnail Creation
  • Cropping
  • Rotating
  • Watermarking
$image = '.upload/gallery/test_image_001.jpg'

$config_manip = array(
    'image_library' => 'gd2',
    'source_image' => $image,
    'new_image' => $image,
    'maintain_ratio' => TRUE,
    'create_thumb' => TRUE,
    'thumb_marker' => '_thumbnaul',
    'width' => 150,
    'height' => 150,


This function will create a 150×150 thumbnail called test_image_001_thumbnail.jpg in ./upload/gallery/.

All available parameters of Image Manipulation can be found on

Leave a Reply

Your email address will not be published. Required fields are marked *