views:

80

answers:

2

I have uploaded an image with the resolution 1600x1200. How can I show users 60x60 and 200x200 without creating thumbnails and uploading again. (like phpthumb library) in CodeIgniter?

+2  A: 

http://codeigniter.com/forums/viewthread/155086/

That's the timThumb controller for CI.

Mike
How to use timThumb? tutorial or documentation?
zarpio
http://www.darrenhoyt.com/2008/04/02/timthumb-php-script-released/ (the tutorial)
Mike
He really needs to add some anti-spam measurements to his forum
stef
+1  A: 

Codeigniter comes with its own image library which can resize images. This example is from the documentation, just edit the $config variable:

$config['image_library'] = 'gd2';
$config['source_image'] = '/path/to/image/mypic.jpg';
$config['new_image'] = '/path/to/new/image.jpg';
$config['maintain_ratio'] = TRUE;
$config['width'] = 75;
$config['height'] = 50;

$this->load->library('image_lib', $config);

$this->image_lib->resize();

You can also create thumbnails dynamically (that is, without saving them to the hard drive) but that requires a lot of memory so I would discourage that.

The image class can also crop the image if you need that. I use it to create thumbnails in the application I am currently working on...

Visit the documentation: http://codeigniter.com/user_guide/libraries/image_lib.html

Calle