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

[eluser]PoWah[/eluser]
I have faced a problem with image resizing. Tried to read some forum post but that didnt help to solve the problem. Here it is the situation: in some directory I have many images of unknown size. I need to resize each of them twice: to make 800x600 image (if needed) ant thumbnail (100x75).
When I loop through directory images and try to resize them, the server drops a fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 8504 bytes)
and here it is the code:
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);
}

any advise? :/


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