Welcome Guest, Not a member yet? Register   Sign In
Image resizing in a loop problem
#4

[eluser]Rick Jolly[/eluser]
I think the problem is that you are creating too many image_lib objects. You don't need to explicitly create a "new CI_Image_Lib();" object since the loader does that for you. Also, you can work with that one image_lib copy instead of creating multiple copies. Maybe try the code posted below:
Code:
$this->load->library("image_lib");

foreach ($images as $image)
{
  // 1st resizing
  // $this->image_lib = new CI_Image_Lib();

  $this->image_lib->clear();
  $config['source_image'] = $image;
  $config['maintain_ratio'] = TRUE;
  $config['width'] = 600;
  $config['height'] = 800;

  $this->image_lib->initialize($config);
  $this->image_lib->resize();
  // unset($this->image_lib); // trying to free the memory, but... :(

  // 2nd resizing
  // $this->image_lib = new CI_Image_Lib();
  
  $this->image_lib->clear();
  $config2['source_image'] = $image;
  $config2['maintain_ratio'] = TRUE;
  $config2['width'] = 75;
  $config2['height'] = 100;

  $this->image_lib->initialize($config2);
  $this->image_lib->resize();
  // unset($this->image_lib);
}


Messages In This Thread
Image resizing in a loop problem - by El Forum - 07-01-2007, 04:27 AM
Image resizing in a loop problem - by El Forum - 07-01-2007, 06:36 AM
Image resizing in a loop problem - by El Forum - 07-01-2007, 07:51 AM
Image resizing in a loop problem - by El Forum - 07-01-2007, 10:52 AM
Image resizing in a loop problem - by El Forum - 07-02-2007, 01:00 AM
Image resizing in a loop problem - by El Forum - 07-02-2007, 01:12 AM
Image resizing in a loop problem - by El Forum - 07-02-2007, 11:41 AM
Image resizing in a loop problem - by El Forum - 07-03-2007, 12:44 AM
Image resizing in a loop problem - by El Forum - 07-03-2007, 01:12 AM
Image resizing in a loop problem - by El Forum - 07-03-2007, 03:46 AM
Image resizing in a loop problem - by El Forum - 07-17-2007, 01:08 AM
Image resizing in a loop problem - by El Forum - 09-16-2007, 08:45 AM



Theme © iAndrew 2016 - Forum software by © MyBB