CodeIgniter Forums
image resize - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: image resize (/showthread.php?tid=5181)



image resize - El Forum - 01-10-2008

[eluser]vbnullchar[/eluser]
how can i resize image then directly displayed in the browser..?


image resize - El Forum - 01-10-2008

[eluser]xwero[/eluser]
Code:
// controller
$file = 'new_image.jpg'
$newpath = '/path/to/'.$file;
if(!file_exist($newpath)) // check for not generating rezized images multiple times
{
   $config['image_library'] = 'GD';
   $config['source_image'] = '/path/to/image/mypic.jpg';
   $config['create_new'] = $newpath; // keeps oringinal
   $config['maintain_ratio'] = TRUE;
   $config['width'] = 75;
   $config['height'] = 50;

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

   $this->image_lib->resize();
}
$data['resizedurl'] = base_url().'to/path/'.$file;
$this->load->view('view',$data);
// view
<img src="&lt;?php echo $resizedurl; ?&gt;">
You can make it more dynamic but i think you can get the picture


image resize - El Forum - 01-10-2008

[eluser]vbnullchar[/eluser]
cool thanks...

setting dynamic_output to TRUE does the trick for me

Code:
$config['dynamic_output'] = TRUE;


thanks again