Strange Problem with Image manipulation class

#1
[eluser]Shouvik-S-Mazumdar[/eluser]
i have two functions - one for creating a thumbnail and another for optimizing a photo ( basically resizing it to a decent 800X600 with lesser quality )

Both these functions work as intended when run individually . However consider a scenario where i am uploading a file . After first uploading i want to create a thumbnail and then optimize it.

Here comes the problem , only one of the following functions work and the other has no effect at all .

the scenario is like

//upload
$filename = "something.jpg"; // getting it from upload data

$this->createThumbnail($filename);
$this->optimizePhoto($filename);


only one of the above functions will execute ( the first one ..the second one has no effect )

ANY HELP ????? its really driving me crazy


Code:
public function createThumbnail($filename)
    {
        
            
        
            /* create a thumbnail and then run the database routine */
            $config['image_library'] = 'gd2';
            $config['source_image'] = './uploads/photo/' . $filename;
            $config['new_image'] = './uploads/photo/thumb/';
            $config['master_dim'] = 'height';
            $config['create_thumb'] = true;
            $config['maintain_ratio'] = false;
            $config['width'] = 100;
            $config['height'] = 75;

            $this->load->library('image_lib', $config);
            /* create a thumbnail */
            $this->image_lib->resize();
            $this->image_lib->clear();
            
            
            
    }


Code:
public function optimizePhoto($filename)
    {
          
                
            /* create a thumbnail and then run the database routine */
            $config['image_library'] = 'gd2';
            $config['source_image'] = './uploads/photo/' . $filename;
            $config['master_dim'] = 'height';
            $config['maintain_ratio'] = false;
            $config['width'] = 800;
            $config['height'] = 600;

            $this->load->library('image_lib', $config);
            /* create a thumbnail */
            $this->image_lib->resize();
        //    $this->image_lib->clear();
    }




Also any help in how facebook / orkut upload optimize uploaded photos ?

#2
[eluser]danmontgomery[/eluser]
load() will only load libraries once unless a custom object name is specified... You should be using initialize() instead.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.