MY Image lib Extension

Derek Jones edited this page Jul 5, 2012 · 5 revisions
Clone this wiki locally

What is it?

A simple extension to add an adaptive resize method to the native CI Image_lib. Just download the library and extract it to your libraries folder.



What does this adaptive_resize method do?

It crops an images. The difference between this extension and the native crop is it first re-sizes the image to your specification and then crops the re-sized image giving you a fixed image size.

How do I use it?

You use it by calling it like you would a native method. Only difference is you must pass two new config values.

$config['ar_width'] = 200;
$config['ar_height'] = 100;
$config['width'] = 200;
$config['height'] = 100;

It is recomended that the ar_width/ar_height are the same as width/height.

Can I see a usage example?


$config['image_library'] = 'gd2';
$config['maintain_ratio'] = TRUE;
$config['width'] = 200;
$config['height'] = 100;
$config['ar_width'] = 200; //new config option
$config['ar_height'] = 100; //new config option
$config['source_image'] = '/path/to/image/imagename.jpg';
$config['new_image'] = '/path/to/saved/image/imagename.jpg';


$this->ci->image_lib->adaptive_resize(); //new method