forked from bcit-ci/CodeIgniter
-
Notifications
You must be signed in to change notification settings - Fork 0
MY Image lib Extension
World Wide Web Server edited this page Jul 4, 2012
·
5 revisions
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.
[url=http://codeigniter.com/wiki/69d1d9e6512160de3f41d4e72976e1f1/]Download[/url]
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.
You use it by calling it like you would a native method. Only difference is you must pass two new config values.
[code]
$config['ar_width'] = 200;
$config['ar_height'] = 100;
$config['width'] = 200;
$config['height'] = 100;
[/code]
It is recomended that the ar_width/ar_height are the same as width/height.
[code] $this->load->library('image_lib');
$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->initialize($config);
$this->ci->image_lib->adaptive_resize(); //new method [/code]