• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CI Image Manipulation

#11
[eluser]phusiondesign[/eluser]
[quote author="elitemedia" date="1205299925"]This is why I call 2 times in my code the resize function... I know, this is not very intuitive to understand why the Image Lib work like that but It's the only way I have found to make what I wanted.[/quote]

Well I figured it out... it resolved around the elements being set that were not needed for the crop and so they caused an error by causing nothing to happen.

Here is the fully functioning code with only one function call per image action... hopefully it helps someone.

Thanks all for your help.

Code:
$config['image_library'] = 'GD2';
$config['maintain_ratio'] = TRUE;
                                    
// create a thumbnail
$config['source_image'] = 'public/images/item_images/'.$item->item_data['image'];
$config['quality'] = 100;
$config['width'] = 200;
$config['height'] = 120;
$config['create_thumb'] = TRUE;
$config['thumb_marker'] = '_th';
$config['maintain_ratio'] = TRUE;
$config['master_dim']   = 'width';

$this->image_lib->initialize($config);
$this->image_lib->resize();
                                            
// crop the thumbnail
$imageName = $this->image_lib->explode_name($item->item_data['image']);
$config['source_image'] = 'public/images/item_images/'.$imageName['name'].'_th'.$imageName['ext'];
                                    
unset($config['width']);
unset($config['height']);
                                    
$config['height'] = 120;
$config['x_axis'] = 0;
$config['y_axis'] = 20;
$config['create_thumb'] = FALSE;
$config['maintain_ratio'] = FALSE;
                                    
$this->image_lib->initialize($config);    
$this->image_lib->crop();


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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