CodeIgniter Forums
How to resize two image with imagelib - 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: How to resize two image with imagelib (/showthread.php?tid=30673)



How to resize two image with imagelib - El Forum - 05-22-2010

[eluser]vishok[/eluser]
i have an array with two different url of image. If i do something like this, i got an error,i mean only the last image will be processed.

The code :
$image = array('pippo.jpg','pluto.jpg');
for ($i=0;$i<count($array);$i++) {
$config['image_library'] = 'gd2';
$config['source_image'] = $array[$i];
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width'] = 75;
$config['height'] = 50;
$config['new_image'] = '/tmp/'.$array[$i];
$this->load->library('image_lib', $config);
$this->image_lib->resize();
$this->image_lib->clear();
}

i got pluto.jpg correctly resized in tmp but i haven't pippo.jpg

How to do this?


How to resize two image with imagelib - El Forum - 05-22-2010

[eluser]Shanto[/eluser]
Try this one:
Code:
&lt;?php
$image = array('pippo.jpg','pluto.jpg');
for ($i=0;$i<count($image);$i++) {
    $config['image_library'] = 'gd2';
    $config['source_image'] = $image[$i];
    $config['create_thumb'] = TRUE;
    $config['maintain_ratio'] = TRUE;
    $config['width'] = 75;
    $config['height'] = 50;
    $config['new_image'] = '/tmp/'.$image[$i].'.jpg';
    $this->load->library('image_lib', $config);
    $this->image_lib->resize();
    $this->image_lib->clear();
}
?&gt;