Home » CodeIgniter »

1

In this post i would like to explain about how to create thumbnail images in codeigniter framework. In the following function will give the clear understand about the code.

Create Thumbnail Function

1
2
3
4
5
6
7
8
9
10
11
function _createThumbnail($fileName) {
$config['image_library'] = 'gd2';
$config['source_image'] = 'uploads/' . $fileName;
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width'] = 75;
$config['height'] = 75;

$this->load->library('image_lib', $config);
if(!$this->image_lib->resize()) echo $this->image_lib->display_errors();
}

Call the above function like :

1
$this->_createThumbnail($fInfo['file_name']);

After creation of thumbnail clear the caches.

1
$this->image_lib->clear();

Hope that it will be useful.


Related Posts

    How to set the pagination in CodeIgniter?Codeigniter multi language support using google translate APIWhat is CodeIgniter,how to install in local system?Understanding the basic need of MVC architecture

 

1 Comment

Leave a Reply