'; } if ($set == 'wireframe_black' || $set == 'wireframe_white') { return ''; } } function new_image($config, $debug = false){ $debug = false; $CI =& get_instance(); $CI->load->library('image_lib'); //Set folder name to desired size if empty if (!$config['destination_folder']) { $config['destination_folder'] = $desired_size; } $config['destination_path'] = './'.$config['base_path'].'/'.$config['destination_folder'].'/'; $config['source_path'] = './'.$config['base_path'].'/src/'; if (!isset($config['center_crop'])) { $config['center_crop'] = false; } if ($debug) { echo APPPATH.'../'.$config['base_path'].'/'.$config['destination_folder']; } //Create destination directory if non-existent if (!is_dir(APPPATH.'../'.$config['base_path'].'/'.$config['destination_folder'])) { mkdir($config['destination_path'], 0777); } //Find the correct width and height if ($config['image_data']['image_width'] <= $config['image_data']['image_height']) { //Height is the longer side if ($config['image_data']['image_height'] > $config['desired_size']) { //Height is more than desired size, continue with resize $ratio = $config['image_data']['image_height'] / $config['image_data']['image_width']; $config['image_data']['image_width_new'] = $config['desired_size']; $config['image_data']['image_height_new'] = $ratio * $config['desired_size']; } else { //Height is less than desired size, keep original size $config['image_data']['image_width_new'] = $config['image_data']['image_width']; $config['image_data']['image_height_new'] = $config['image_data']['image_height']; } } else { //Width is the longer side if ($config['image_data']['image_width'] > $config['desired_size']) { //Width is more than desired size, continue with resize $ratio = $config['image_data']['image_width'] / $config['image_data']['image_height']; $config['image_data']['image_width_new'] = $ratio * $config['desired_size']; $config['image_data']['image_height_new'] = $config['desired_size']; } else { //Width is less than desired size, keep original size $config['image_data']['image_width_new'] = $config['image_data']['image_width']; $config['image_data']['image_height_new'] = $config['image_data']['image_height']; } } //If dimensions are forced, the longer side is set to the desired size if ($config['force_dimensions'] && $config['image_data']['image_width_new'] >= $config['desired_size'] && $config['image_data']['image_height_new'] >= $config['desired_size']) { if ($config['image_data']['image_width_new'] >= $config['image_data']['image_height_new']) { $ratio = $config['desired_size'] / $config['image_data']['image_width']; $config['image_data']['image_width_new'] = $config['desired_size']; $config['image_data']['image_height_new'] = $ratio * $config['image_data']['image_height']; } else { $ratio = $config['desired_size'] / $config['image_data']['image_height']; $config['image_data']['image_width_new'] = $ratio * $config['image_data']['image_width']; $config['image_data']['image_height_new'] = $config['desired_size']; } } //Fixes to the desired height if (isset($config['follow_height'])) { if ($config['follow_height'] && $config['image_data']['image_width_new'] >= $config['desired_size'] && $config['image_data']['image_height_new'] >= $config['desired_size']) { $ratio = $config['desired_size'] / $config['image_data']['image_height']; $config['image_data']['image_width_new'] = $ratio * $config['image_data']['image_width']; $config['image_data']['image_height_new'] = $config['desired_size']; } } //Round off the dimensions $config['image_data']['image_width_new'] = round($config['image_data']['image_width_new']); $config['image_data']['image_height_new'] = round($config['image_data']['image_height_new']); //Build the configuration file for the image library $CI->image_lib->clear(); $image_library_config['image_library'] = 'gd2'; $image_library_config['source_image'] = $config['source_path'].$config['image_data']['file_name']; $image_library_config['new_image'] = $config['destination_path']; $image_library_config['maintain_ratio'] = TRUE; $image_library_config['width'] = $config['image_data']['image_width_new']; $image_library_config['height'] = $config['image_data']['image_height_new']; //Do the resize $CI->image_lib->initialize($image_library_config); if ( !$CI->image_lib->resize()) { $data['resize_error'] = $CI->image_lib->display_errors(); $upload = false; } //If crop is set, process crop settings if ($config['crop']) { $CI->image_lib->clear(); $image_library_crop_config['image_library'] = 'gd2'; $image_library_crop_config['source_image'] = $config['destination_path'].$config['image_data']['file_name']; $image_library_crop_config['maintain_ratio'] = FALSE; if (!empty($config['crop_x'])) { $image_library_crop_config['width'] = $config['crop_x']; } else { $image_library_crop_config['width'] = $config['desired_size']; } if (!empty($config['crop_y'])) { $image_library_crop_config['height'] = $config['crop_y']; } else { $image_library_crop_config['height'] = $config['desired_size']; } if ($config['center_crop']) { $image_library_crop_config['x_axis'] = ($config['image_data']['image_width_new'] - $config['crop_x']) / 2; $image_library_crop_config['y_axis'] = ($config['image_data']['image_height_new'] - $config['crop_y']) / 2; } else { $image_library_crop_config['x_axis'] = '0'; $image_library_crop_config['y_axis'] = '0'; } $CI->image_lib->initialize($image_library_crop_config); if ( !$CI->image_lib->crop()) { $data['resize_error'] = $CI->image_lib->display_errors(); $upload = false; } } if ($debug) { echo '

'; echo $config['destination_folder']; echo '

'; echo '
';
		print_r($config);
		echo '
'; echo '
';
		print_r($image_library_config);
		echo '
'; if (isset($image_library_crop_config)) { echo '
';
			print_r($image_library_crop_config);
			echo '
'; } echo '
'; if ($config['crop']) { if ($config['center_crop']) { echo ''; } else { echo ''; } } else { echo ''; } echo '
'; } } ?>template->write('pageTabs', ''); } function addLink($link, $name, $extra = NULL) { $return = ''; $CI =& get_instance(); //Check if active link if ($CI->uri->uri_string() == $link) { $return .= '
  • '; } else { $return .= '
  • '; } $return .= anchor($link, $name, $extra); $return .= '
  • '; return $return; } ?> info | Addi.is - Addi ljósmyndari ehf - 824 6161