Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private function crop_image($width, $height, $path, $new_path = false)
- {
- $this->load->library('image_lib');
- $this->image_lib->clear();
- $config['image_library'] = 'gd2';
- $config['source_image'] = $path;
- if ( $new_path ) $config['new_image'] = $new_path;
- if ($width>$height) {
- $config['width'] = round(($width/$height) * 135);
- $config['height'] = 135;
- }
- else {
- $config['width'] = 135;
- $config['height'] = round(($height/$width) * 135);
- }
- $new_width=$config['width'];
- $new_height=$config['height'];
- $config['maintain_ratio'] = TRUE;
- $config['quality'] = '95%';
- $this->image_lib->initialize($config);
- $this->image_lib->resize();
- $config['image_library'] = 'gd2';
- $config['source_image'] = $new_path;
- if ( $new_path ) $config['new_image'] = $new_path;
- $config['width'] = 135;
- $config['height'] = 135;
- $config['maintain_ratio'] = FALSE;
- $config['quality'] = '95%';
- if ($new_width>$new_height) {
- $config['x_axis'] = round((135-$new_width) / 2);
- $config['y_axis'] = 0;
- }
- else {
- $config['x_axis'] = 0;
- $config['y_axis'] = round((135-$new_height) / 2);
- }
- $this->image_lib->initialize($config);
- return $this->image_lib->crop();
- }
Add Comment
Please, Sign In to add comment