Skip to content

MY Image lib Extension

Derek Jones edited this page Jul 5, 2012 · 5 revisions

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.

Download

[Download](http://codeigniter.com/wiki/69d1d9e6512160de3f41d4e72976e1f1/)

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. ```php

$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.

<h2>Can I see a usage example?</h2>

```php

$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

Clone this wiki locally