• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Croping problem

#1
[eluser]lucky8919[/eluser]
Hi there,

I'm having a problem when I've to resize and crop an image. For some reason after the cropping process is finish it's leaving a grey space between the image and the space that was cropped.

This is my code:

Code:
$w_orig = $file_data['image_width'];
  $h_orig = $file_data['image_height'];
  
  if ( $w_orig > $this->config['width'] )
  {
   $w_med = $this->config['width'];
   $h_med = ( $h_orig * $this->config['width'] ) / $w_orig;
  }
  else
  {
   $w_med  = $w_orig;
   $h_med  = $h_orig;
  }
  
  // global config
  $config['image_library']  = 'gd2';
  $config['source_image']  = $file_data['full_path'];
  $config['create_thumb']  = FALSE;
  $config['maintain_ratio']  = FALSE;
  $config['width']         = $w_med;
  $config['height']        = $h_med;
  
  $this->CI->image_lib->initialize ( $config );
  $this->CI->image_lib->resize();
  
  $imageSize = $this->CI->image_lib->get_image_properties($config['source_image'], TRUE);
  
    // axis settings
  $config['image_library']  = 'gd';
  $config['source_image']  = $file_data['full_path'];
  $config['create_thumb']  = FALSE;
  $config['maintain_ratio']  = FALSE;
  $config['x_axis']         = 0;
  $config['y_axis']        = ( ( $imageSize['height'] / 2 ) - ( $this->config['height'] / 2 ) );
  
  $this->CI->image_lib->initialize ( $config );
  $this->CI->image_lib->crop();
  $this->CI->image_lib->clear();

I'm leaving an image so you can see more clearly what my problem is.

I hope you can help me.

Thanks!

#2
[eluser]lucky8919[/eluser]
Please, anyone can help me with this?

#3
[eluser]lucky8919[/eluser]
This solve my problem. I hope it can helps.

http://kennykee.com/138/codeigniter-resi...v-example/


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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