How to Create a Thumbnail with CodeIgnitor

Uploading images is a common task on almost every website. 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 on the list page. CodeIgniter provides a nice built-in library for creating thumbnails without having to write a lot of code.

CodeIgnitor provides a built-in class called Image Manipulation to make creating thumbnails 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 at

Leave a Comment

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

Scroll to Top

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.