AAAAPK)ž?\›Êü++image_resize.phpnuW+A„¶ 'form_utilities', 'title' => 'Utilities'); var $details = array('title' => 'Image Resize', 'tooltip' => 'Do some images resizing operations.'); function run($form, $actiondata){ $params = new JParameter($actiondata->params); $mainframe = JFactory::getApplication(); //set the images path $upload_path = $params->get('upload_path', ''); if(!empty($upload_path)){ $upload_path = str_replace(array("/", "\\"), DS, $upload_path); if(substr($upload_path, -1) == DS){ $upload_path = substr_replace($upload_path, '', -1); } $upload_path = str_replace("JOOMLA_PATH", JPATH_SITE, $upload_path).DS; $params->set('upload_path', $upload_path); }else{ $upload_path = JPATH_SITE.DS.'components'.DS.'com_chronoforms'.DS.'uploads'.DS.$form->form_details->name.DS; } $image_file_name = $params->get('photo', ''); if(strpos($image_file_name, ',') !== false){ $image_file_names = explode(',', $image_file_name); }else{ $image_file_names = array($image_file_name); } foreach($image_file_names as $image_file_name){ //stop if the field name is not set or if the file data doesn't exist //if((strlen($image_file_name) == 0) || !isset($form->data[$image_file_name]) || !isset($form->files[$image_file_name]['path'])){ if((strlen($image_file_name) == 0) || !isset($form->files[$image_file_name])){ continue; } if($form->files[$image_file_name] === array_values($form->files[$image_file_name])){ //array of files $reset = false; }else{ $form->files[$image_file_name] = array($form->files[$image_file_name]); $reset = true; } foreach($form->files[$image_file_name] as $k => $image){ // Common parameters $photo = $image['name'];//$form->data[$image_file_name]; $filein = $image['path']; $file_info = pathinfo($filein); $form->debug['Image_Resize'][$actiondata->order]['thumb_big'] = $form->files[$image_file_name][$k]['thumb_big'] = $this->processSize('big', $form, $actiondata, $photo, $filein, $upload_path, $file_info); // treatment of the medium image $form->debug['Image_Resize'][$actiondata->order]['thumb_med'] = $form->files[$image_file_name][$k]['thumb_med'] = $this->processSize('med', $form, $actiondata, $photo, $filein, $upload_path, $file_info); // treatment of the small image $form->debug['Image_Resize'][$actiondata->order]['thumb_small'] = $form->files[$image_file_name][$k]['thumb_small'] = $this->processSize('small', $form, $actiondata, $photo, $filein, $upload_path, $file_info); if($params->get('delete_original')){ unlink($filein); } } if($reset){ $form->files[$image_file_name] = $form->files[$image_file_name][0]; } } } function processSize($size = 'big', $form, $actiondata, $photo, $filein, $upload_path, $file_info){ $params = new JParameter($actiondata->params); $quality = $params->get('quality', 90); $dir = ''; if($params->get($size.'_directory', '')){ $dir .= $params->get($size.'_directory', ''); } else { $dir .= $upload_path; } // add a final slash if needed if(substr($dir, -1) != DS){ $dir .= DS; } $fileout = $dir.$params->get($size.'_image_prefix', '').str_replace('.'.$file_info['extension'], '', $photo).$params->get($size.'_image_suffix', '').'.'.$file_info['extension']; $crop = $params->get($size.'_image_method', 0); $imagethumbsize_w = $params->get($size.'_image_width', 400); $imagethumbsize_h = $params->get($size.'_image_height', 300); $red = $params->get($size.'_image_r', 255); $green = $params->get($size.'_image_g', 255); $blue = $params->get($size.'_image_b', 255); $use = $params->get($size.'_image_use', 0); if($size == 'big'){ $use = true; } if($use){ if($crop){ $this->resizeThenCrop($filein, $fileout, $imagethumbsize_w, $imagethumbsize_h, $red, $green, $blue, $quality); }else{ $this->resize($filein, $fileout, $imagethumbsize_w, $imagethumbsize_h, $red, $green, $blue, $quality); } return $params->get($size.'_image_prefix', '').str_replace('.'.$file_info['extension'], '', $photo).$params->get($size.'_image_suffix', '').'.'.$file_info['extension']; } return null; } function resizeThenCrop( $filein, $fileout, $imagethumbsize_w, $imagethumbsize_h, $red, $green, $blue, $quality ) { // Cacul des nouvelles dimensions list($width, $height) = getimagesize($filein); //$new_width = $width * $percent; //$new_height = $height * $percent; if ( preg_match("/.jpg/i", "$filein") || preg_match("/.jpeg/i", "$filein") ) { $format = 'image/jpeg'; } elseif ( preg_match("/.gif/i", "$filein") ) { $format = 'image/gif'; } else if( preg_match("/.png/i", "$filein") ) { $format = 'image/png'; } switch($format) { case 'image/jpeg': $image = imagecreatefromjpeg($filein); break; case 'image/gif'; $image = imagecreatefromgif($filein); break; case 'image/png': $image = imagecreatefrompng($filein); break; } $width = $imagethumbsize_w ; $height = $imagethumbsize_h ; list($width_orig, $height_orig) = getimagesize($filein); if ( $width_orig < $height_orig ) { $height = ($imagethumbsize_w / $width_orig) * $height_orig; } else { $width = ($imagethumbsize_h / $height_orig) * $width_orig; } if ( $width < $imagethumbsize_w ) { // If the image width is less than the thumbnail $width = $imagethumbsize_w; $height = ($imagethumbsize_w / $width_orig) * $height_orig; } if ( $height < $imagethumbsize_h ) { // If the image height is less than the thumbnail $height = $imagethumbsize_h; $width = ($imagethumbsize_h / $height_orig) * $width_orig; } $thumb = imagecreatetruecolor($width , $height); $bgcolor = imagecolorallocate($thumb, $red, $green, $blue); ImageFilledRectangle($thumb, 0, 0, $width, $height, $bgcolor); imagealphablending($thumb, true); imagecopyresampled($thumb, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); $thumb2 = imagecreatetruecolor($imagethumbsize_w , $imagethumbsize_h); // true color for better quality $bgcolor = imagecolorallocate($thumb2, $red, $green, $blue); ImageFilledRectangle($thumb2, 0, 0, $imagethumbsize_w, $imagethumbsize_h, $bgcolor); imagealphablending($thumb2, true); $w1 = ($width / 2) - ($imagethumbsize_w / 2); $h1 = ($height / 2) - ($imagethumbsize_h / 2); imagecopyresampled($thumb2, $thumb, 0, 0, $w1, $h1,$imagethumbsize_w, $imagethumbsize_h, $imagethumbsize_w, $imagethumbsize_h); // create the file switch($format) { case 'image/jpeg': imagejpeg($thumb2, $fileout, $quality); break; case 'image/gif'; imagegif($thumb2, $fileout); break; case 'image/png': imagepng($thumb2, $fileout); break; } } function resize( $filein, $fileout, $imagethumbsize_w, $imagethumbsize_h, $red, $green, $blue, $quality ) { // Cacul des nouvelles dimensions list($width_orig, $height_orig) = getimagesize($filein); if ( preg_match("/.jpg/i", "$filein") || preg_match("/.jpeg/i", "$filein") ) { $format = 'image/jpeg'; } if ( preg_match("/.gif/i", "$filein") ) { $format = 'image/gif'; } if ( preg_match("/.png/i", "$filein") ) { $format = 'image/png'; } switch ( $format ) { case 'image/jpeg': $image = imagecreatefromjpeg($filein); break; case 'image/gif'; $image = imagecreatefromgif($filein); break; case 'image/png': $image = imagecreatefrompng($filein); break; } $ratio_orig = $width_orig/$height_orig; if ($imagethumbsize_w/$imagethumbsize_h > $ratio_orig) { $imagethumbsize_w = $imagethumbsize_h*$ratio_orig; } else { $imagethumbsize_h = $imagethumbsize_w/$ratio_orig; } // Redimensionnement $thumb3 = imagecreatetruecolor($imagethumbsize_w, $imagethumbsize_h); $bgcolor = imagecolorallocate($thumb3, $red, $green, $blue); ImageFilledRectangle($thumb3, 0 ,0 ,$imagethumbsize_w, $imagethumbsize_h, $bgcolor); imagealphablending($thumb3, true); imagecopyresampled($thumb3, $image, 0, 0, 0, 0, $imagethumbsize_w, $imagethumbsize_h, $width_orig, $height_orig); switch ( $format ) { case 'image/jpeg': imagejpeg($thumb3, $fileout, $quality); // on cree le fichier break; case 'image/gif'; imagegif($thumb3, $fileout); // on cree le fichier break; case 'image/png': imagepng($thumb3, $fileout); // on cree le fichier break; } } function load($clear){ if($clear){ $action_params = array( 'photo' => '', 'delete_original' => 0, 'quality' => 90, 'big_directory' => '', 'big_image_use' => '1', 'big_image_prefix' => '', 'big_image_suffix' => '_big', 'big_image_height' => '300', 'big_image_width' => '400', 'big_image_r' => '255', 'big_image_g' => '255', 'big_image_b' => '255', 'big_image_method' => '0', 'med_directory' => '', 'med_image_use' => '0', 'med_image_prefix' => '', 'med_image_suffix' => '_med', 'med_image_height' => '300', 'med_image_width' => '400', 'med_image_r' => '255', 'med_image_g' => '255', 'med_image_b' => '255', 'med_image_method' => '0', 'small_image_use' => '0', 'small_directory' => '', 'small_image_prefix' => '', 'small_image_suffix' => '_small', 'small_image_height' => '300', 'small_image_width' => '400', 'small_image_r' => '255', 'small_image_g' => '255', 'small_image_b' => '255', 'small_image_method' => '0' ); } return array('action_params' => $action_params); } } ?>PK)ž?\®)ÕÐ .htaccessnuW+A„¶ Order allow,deny Deny from all PK)ž?\ž ÙÜ index.htmlnuW+A„¶ PK)ž?\¤AfJ ; ;image_resize.ctpnuW+A„¶
Image Resize
Header(array('settings' => 'General', 'medium_image' => 'Medium Image', 'small_image' => 'Small Image'), 'image_resize_config_{n}'); ?> tabStart('settings'); ?> input('action_image_resize_{n}_delete_original_config', array('type' => 'select', 'label' => 'Delete Original', 'options' => array(0 => 'No', 1 => 'Yes'), 'smalldesc' => 'Delete the original image from the upload directory')); ?> input('action_image_resize_{n}_photo_config', array('type' => 'text', 'label' => 'Image field name', 'class' => 'medium_input', 'value' => '')); ?> input('action_image_resize_{n}_quality_config', array('type' => 'text', 'label' => 'Output image(s) quality', 'class' => 'medium_input', 'smalldesc' => 'set the quality of ouput jpg images')); ?> input('action_image_resize_{n}_big_directory_config', array('type' => 'text', 'label' => 'Big image directory', 'class' => 'medium_input', 'smalldesc' => 'Directory where the file will be stored. Don\'t forget the slash at the end ;-) e.g. images/stories/
If you leave this empty it will default to the Form file uploads folder.')); ?> input('action_image_resize_{n}_big_image_prefix_config', array('type' => 'text', 'label' => 'Big image name prefix', 'class' => 'medium_input', 'smalldesc' => 'The prefix for the created image name e.g. big_')); ?> input('action_image_resize_{n}_big_image_suffix_config', array('type' => 'text', 'label' => 'Big image name suffix', 'class' => 'medium_input', 'smalldesc' => 'The suffix for the created image name e.g. _big')); ?> input('action_image_resize_{n}_big_image_height_config', array('type' => 'text', 'label' => 'Big image height', 'class' => 'medium_input', 'value' => '')); ?> input('action_image_resize_{n}_big_image_width_config', array('type' => 'text', 'label' => 'Big image width', 'class' => 'medium_input', 'value' => '')); ?> input('action_image_resize_{n}_big_image_r_config', array('type' => 'text', 'label' => 'Big image R color', 'class' => 'medium_input', 'smalldesc' => 'Alpha channel for png transparency. RGB color of the background.')); ?> input('action_image_resize_{n}_big_image_g_config', array('type' => 'text', 'label' => 'Big image G color', 'class' => 'medium_input', 'smalldesc' => 'Alpha channel for png transparency. RGB color of the background.')); ?> input('action_image_resize_{n}_big_image_b_config', array('type' => 'text', 'label' => 'Big image B color', 'class' => 'medium_input', 'smalldesc' => 'Alpha channel for png transparency. RGB color of the background.')); ?> input('action_image_resize_{n}_big_image_method_config', array('type' => 'select', 'label' => 'Big image processing method', 'options' => array(0 => 'Resize', 1 => 'Resize & Crop'), 'smalldesc' => 'The way your images will be generated (either scale or crop)')); ?> tabEnd(); ?> tabStart('medium_image'); ?> input('action_image_resize_{n}_med_image_use_config', array('type' => 'select', 'label' => 'Enable Medium image', 'options' => array(0 => 'No', 1 => 'Yes'), 'smalldesc' => 'Should we generate a medium sized image ?')); ?> input('action_image_resize_{n}_med_directory_config', array('type' => 'text', 'label' => 'Medium image directory', 'class' => 'medium_input', 'smalldesc' => 'Directory where the file will be stored. Don\'t forget the slash at the end ;-) e.g. images/stories/
If you leave this empty it will default to the Form file uploads folder.')); ?> input('action_image_resize_{n}_med_image_prefix_config', array('type' => 'text', 'label' => 'Medium image name prefix', 'class' => 'medium_input', 'smalldesc' => 'The prefix for the created image name e.g. med_')); ?> input('action_image_resize_{n}_med_image_suffix_config', array('type' => 'text', 'label' => 'Medium image name suffix', 'class' => 'medium_input', 'smalldesc' => 'The suffix for the created image name e.g. _med')); ?> input('action_image_resize_{n}_med_image_height_config', array('type' => 'text', 'label' => 'Medium image height', 'class' => 'medium_input', 'value' => '')); ?> input('action_image_resize_{n}_med_image_width_config', array('type' => 'text', 'label' => 'Medium image width', 'class' => 'medium_input', 'value' => '')); ?> input('action_image_resize_{n}_med_image_r_config', array('type' => 'text', 'label' => 'Medium image R color', 'class' => 'medium_input', 'smalldesc' => 'Alpha channel for png transparency. RGB color of the background.')); ?> input('action_image_resize_{n}_med_image_g_config', array('type' => 'text', 'label' => 'Medium image G color', 'class' => 'medium_input', 'smalldesc' => 'Alpha channel for png transparency. RGB color of the background.')); ?> input('action_image_resize_{n}_med_image_b_config', array('type' => 'text', 'label' => 'Medium image B color', 'class' => 'medium_input', 'smalldesc' => 'Alpha channel for png transparency. RGB color of the background.')); ?> input('action_image_resize_{n}_med_image_method_config', array('type' => 'select', 'label' => 'Medium image processing method', 'options' => array(0 => 'Resize', 1 => 'Resize & Crop'), 'smalldesc' => 'The way your images will be generated (either scale or crop)')); ?> tabEnd(); ?> tabStart('small_image'); ?> input('action_image_resize_{n}_small_image_use_config', array('type' => 'select', 'label' => 'Enable Small image', 'options' => array(0 => 'No', 1 => 'Yes'), 'smalldesc' => 'Should we generate a small sized image ?')); ?> input('action_image_resize_{n}_small_directory_config', array('type' => 'text', 'label' => 'Small image directory', 'class' => 'medium_input', 'smalldesc' => 'Directory where the file will be stored. Don\'t forget the slash at the end ;-) e.g. images/stories/
If you leave this empty it will default to the Form file uploads folder.')); ?> input('action_image_resize_{n}_small_image_prefix_config', array('type' => 'text', 'label' => 'Small image name prefix', 'class' => 'medium_input', 'smalldesc' => 'The prefix for the created image name e.g. small_')); ?> input('action_image_resize_{n}_small_image_suffix_config', array('type' => 'text', 'label' => 'Small image name suffix', 'class' => 'medium_input', 'smalldesc' => 'The suffix for the created image name e.g. _small')); ?> input('action_image_resize_{n}_small_image_height_config', array('type' => 'text', 'label' => 'Small image height', 'class' => 'medium_input', 'value' => '')); ?> input('action_image_resize_{n}_small_image_width_config', array('type' => 'text', 'label' => 'Small image width', 'class' => 'medium_input', 'value' => '')); ?> input('action_image_resize_{n}_small_image_r_config', array('type' => 'text', 'label' => 'Small image R color', 'class' => 'medium_input', 'smalldesc' => 'Alpha channel for png transparency. RGB color of the background.')); ?> input('action_image_resize_{n}_small_image_g_config', array('type' => 'text', 'label' => 'Small image G color', 'class' => 'medium_input', 'smalldesc' => 'Alpha channel for png transparency. RGB color of the background.')); ?> input('action_image_resize_{n}_small_image_b_config', array('type' => 'text', 'label' => 'Small image B color', 'class' => 'medium_input', 'smalldesc' => 'Alpha channel for png transparency. RGB color of the background.')); ?> input('action_image_resize_{n}_small_image_method_config', array('type' => 'select', 'label' => 'Small image processing method', 'options' => array(0 => 'Resize', 1 => 'Resize & Crop'), 'smalldesc' => 'The way your images will be generated (either scale or crop)')); ?> tabEnd(); ?>
PK)ž?\›Êü++image_resize.phpnuW+A„¶PK)ž?\®)ÕÐ G+.htaccessnuW+A„¶PK)ž?\ž ÙÜ ÿ+index.htmlnuW+A„¶PK)ž?\¤AfJ ; ;V,image_resize.ctpnuW+A„¶PK3£g