CodeIgniter Forums
Problem with Image Manipulation Library - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: Problem with Image Manipulation Library (/showthread.php?tid=72753)



Problem with Image Manipulation Library - webdevron - 02-07-2019

I want to compress the image by 60%. My code is given bellow. I have uploaded an image of 627Kb. The code block is executed but not compressing. Is there any error in my code?

Thanks in advance.

PHP Code:
$this->load->library('image_lib');
if(
$this->upload->data('file_size') > 300){
 
   $config['image_library'   'gd2';
 
   $config['source_image'    $this->upload->data('full_path');
 
   $config['quality'         '60%'// Also tried $config['quality']          = 60;
 
   $config['new_image'       $this->upload->data('full_path');
 
   $this->image_lib->clear();
 
   $this->image_lib->initialize($config);
 
   $this->image_lib->resize();
    echo 
'I am ok';




RE: Problem with Image Manipulation Library - php_rocs - 02-07-2019

@webdevron,

No sure if $config['image-library'] value should be 'GD2' instead 'gd2' according to documentation ( https://www.codeigniter.com/userguide3/libraries/image_lib.html#preferences )


RE: Problem with Image Manipulation Library - adamoli - 02-08-2019

Make sure you're using a jpeg image since you won't be able to compress other types.
Also try not to use same value for source_image and new_image as it'll make it harder to test/debub.


RE: Problem with Image Manipulation Library - InsiteFX - 02-09-2019

Did you use:

PHP Code:
echo $this->image_lib->display_errors(); 

To see if you have some type of error?

Your path looks funny using 'full_path' this needs to be an absolute path.