CodeIgniter Forums
Image Resizing - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Image Resizing (/thread-33820.html)



Image Resizing - El Forum - 09-09-2010

[eluser]Philo01[/eluser]
Hi all! Smile

I have a small problem with resizing images.

Code:
$config['source_image'] = $uploaddata['full_path'];
            $config['width'] = 800;
            $config['height'] = 600;
            $this->load->library('image_lib', $config);
            
            if($this->image_lib->resize()){
                log_message('debug', 'Image has been resized to light box dimensions');
            }
            
            $this->image_lib->clear();
            
            $config['source_image'] = $uploaddata['full_path'];
            $config['width'] = 300;
            $config['height'] = 300;
            $config['create_thumb'] = TRUE;
            $config['new_image'] = $upload_dir;
            
            $this->load->library('image_lib', $config);
            
            if($this->image_lib->resize()){
                log_message('debug', 'Image copy has been made and resized');
            }

Now the strange part is, that it does runs the first resize code.
When it goes to the second part that create's a thumb it gives the following error:

"Your server does not support the GD function required to process this type of image"

I am using GD2. I also tried to simply resize the image again (so no thumb etc, just the the first resize code) but it gives the same error.
So basically everything after the first resize returns an error.

Anyone who can help me out with this Smile

Would appreciate it!

Thanks!


Image Resizing - El Forum - 09-09-2010

[eluser]Philo01[/eluser]
When I the following code when setting up the settings for the second resize it works:

Code:
$this->load->library('image_lib', $config);

Code:
$this->image_lib->initialize($config);

But, it does not create a thumbnail sadly Sad
It just overwrites the one I resized in step 1.


Image Resizing - El Forum - 09-09-2010

[eluser]Philo01[/eluser]
Got it fixed by manually setting the new filename:

Code:
$config['new_image'] = 'thumb_'.$uploaddata['file_name'];