Welcome Guest, Not a member yet? Register   Sign In
resize img two times
#1

[eluser]Unknown[/eluser]
Hello,
so the problem is this: I upload image, call my create thumb function and it creates the first file but not the second? And I don't know why.

My code:
Code:
function _createThumb($fileName){
   $this->load->library('image_lib');

   $this->image_lib->clear();
   $config['image_library'] = 'gd2';
   $config['source_image'] = 'media/uploads/pictures/' . $fileName;
   $config['new_image'] = 'media/uploads/pictures/thumbs/' . $fileName;
   $config['maintain_ratio'] = TRUE;
   $config['width'] = 150;
   $config['height'] = 100;
   $this->image_lib->initialize($config);
        
   if(!$this->image_lib->resize()){
       return $this->image_lib->display_errors();
   }
  
   $this->image_lib->clear();
   $config['new_image'] = 'media/uploads/pictures/thumbs2/' . $fileName;
   $config['width'] = 200;
   $config['height'] = 150;
   $this->image_lib->initialize($config);

   if(!$this->image_lib->resize()){
       return $this->image_lib->display_errors();
   }

   return 1;
}

I get no error Undecided
#2

[eluser]fesweb[/eluser]
I might be under-thinking this, but it looks like you need to provide a $config['source_image'] for the second resize.
#3

[eluser]fesweb[/eluser]
Also, image_lib->clear() does NOT reset config params to their defaults, so you should re-declare all of the params that are important to the second resizing.
#4

[eluser]Unknown[/eluser]
My code works fine as it is. I was being an idiot ccc.

Somehow I managed to copy(not move) my controller folder outside my application folder and then open my .php file in that wrong folder.
Noticed something was wrong when I started changing other things(like returning text instead of 1) and nothing was happening, till then I thought something was wrong with lib and I was messing only with it settings. Silly me.
Noticed this quite quickly but I'm slow on replying.

Thank your for replies anyway Smile




Theme © iAndrew 2016 - Forum software by © MyBB