Welcome Guest, Not a member yet? Register   Sign In
How to resize two image with imagelib
#1

[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?
#2

[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;




Theme © iAndrew 2016 - Forum software by © MyBB