Changeset 13035
- Timestamp:
- Feb 5, 2012, 3:58:14 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/derivatives.php
r13021 r13035 68 68 $errors[$type]['crop'] = '[0..100]'; 69 69 } 70 70 71 71 if ($v!=0) 72 72 { … … 82 82 } 83 83 } 84 84 85 85 if (count($errors)==0) 86 86 { … … 88 88 $prev_h = intval($pderivative['h']); 89 89 } 90 90 91 91 $v = intval($pderivative['sharpen']); 92 92 if ($v<0 || $v>100) … … 127 127 $watermark->opacity = intval($pwatermark['opacity']); 128 128 $watermark->min_size = array(intval($pwatermark['minw']),intval($pwatermark['minh'])); 129 129 130 130 $old_watermark = ImageStdParams::get_watermark(); 131 $watermark_changed = 131 $watermark_changed = 132 132 $watermark->file != $old_watermark->file 133 133 || $watermark->xpos != $old_watermark->xpos … … 136 136 || $watermark->opacity != $old_watermark->opacity; 137 137 ImageStdParams::set_watermark($watermark); 138 138 139 139 $enabled = ImageStdParams::get_defined_type_map(); 140 140 $disabled = @unserialize( @$conf['disabled_derivatives'] ); … … 144 144 } 145 145 $changed_types = array(); 146 146 147 147 foreach(ImageStdParams::get_all_types() as $type) 148 148 { 149 149 $pderivative = $pderivatives[$type]; 150 150 151 151 if ($pderivative['enabled']) 152 152 { 153 153 $new_params = new DerivativeParams( 154 new SizingParams( 154 new SizingParams( 155 155 array(intval($pderivative['w']), intval($pderivative['h'])), 156 156 round($pderivative['crop'] / 100, 2), 157 157 array(intval($pderivative['minw']), intval($pderivative['minh'])) 158 ) 158 ) 159 159 ); 160 160 $new_params->sharpen = intval($pderivative['sharpen']); 161 161 $new_params->quality = intval($pderivative['quality']); 162 162 ImageStdParams::apply_global($new_params); 163 163 164 164 if (isset($enabled[$type])) 165 165 { … … 172 172 } 173 173 174 if ( $same && $new_params->sizing->max_crop != 0 174 if ( $same && $new_params->sizing->max_crop != 0 175 175 && !size_equals($old_params->sizing->min_size, $new_params->sizing->min_size) ) 176 176 { … … 178 178 } 179 179 180 if ( $same && 180 if ( $same && 181 181 ( $new_params->sharpen != $old_params->sharpen 182 182 || $new_params->quality > $old_params->quality) … … 185 185 $same = false; 186 186 } 187 187 188 188 if ($same && 189 ( $new_params->use_watermark != $old_params->use_watermark 189 ( $new_params->use_watermark != $old_params->use_watermark 190 190 || $new_params->use_watermark && $watermark_changed ) 191 191 ) … … 193 193 $same = false; 194 194 } 195 195 196 196 if (!$same) 197 197 { … … 229 229 $enabled_by[$type] = $enabled[$type]; 230 230 } 231 } 231 } 232 232 ImageStdParams::set_and_save($enabled_by); 233 233 if (count($disabled)==0) … … 241 241 } 242 242 $conf['disabled_derivatives']=serialize($disabled); 243 243 244 244 if (count($changed_types)) 245 245 { … … 299 299 } 300 300 $template->assign('derivatives', $tpl_vars); 301 301 302 302 $wm = ImageStdParams::get_watermark(); 303 303 $template->assign('watermark', array( … … 317 317 $watermark_files[] = substr($file, strlen(PHPWG_ROOT_PATH)); 318 318 } 319 foreach (glob(PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'watermarks/*.png') as $file) 320 { 321 $watermark_files[] = substr($file, strlen(PHPWG_ROOT_PATH)); 322 } 319 323 $watermark_filemap = array( '' => '---' ); 320 324 foreach( $watermark_files as $file) -
trunk/admin/include/image.class.php
r12956 r13035 424 424 { 425 425 $this->image->setInterlaceScheme(Imagick::INTERLACE_LINE); 426 if ($this->get_width()%2 == 0 && $this->get_height()%2 == 0 427 && $this->get_width() > 3*$width) 428 { 429 $this->image->scaleImage($this->get_width()/2, $this->get_height()/2); 430 } 426 431 return $this->image->resizeImage($width, $height, Imagick::FILTER_LANCZOS, 0.9); 427 432 } -
trunk/include/derivative_params.inc.php
r13021 r13035 71 71 } 72 72 73 function crop_h($pixels, $coi , $force)73 function crop_h($pixels, $coi) 74 74 { 75 75 if ($this->width() <= $pixels) … … 83 83 $availableL = $coil > $this->l ? $coil - $this->l : 0; 84 84 $availableR = $coir < $this->r ? $this->r - $coir : 0; 85 if ($availableL + $availableR <= $pixels) 86 { 87 if (!$force) 88 { 89 $pixels = $availableL + $availableR; 90 $tlcrop = $availableL; 91 } 92 } 93 else 85 if ($availableL + $availableR >= $pixels) 94 86 { 95 87 if ($availableL < $tlcrop) … … 107 99 } 108 100 109 function crop_v($pixels, $coi , $force)101 function crop_v($pixels, $coi) 110 102 { 111 103 if ($this->height() <= $pixels) … … 119 111 $availableT = $coit > $this->t ? $coit - $this->t : 0; 120 112 $availableB = $coib < $this->b ? $this->b - $coib : 0; 121 if ($availableT + $availableB <= $pixels) 122 { 123 if (!$force) 124 { 125 $pixels = $availableT + $availableB; 126 $tlcrop = $availableT; 127 } 128 } 129 else 113 if ($availableT + $availableB >= $pixels) 130 114 { 131 115 if ($availableT < $tlcrop) … … 199 183 if ($h < $this->min_size[1]) 200 184 { 201 $idealCropPx = $destCrop->width() - round($destCrop->height() * $this->ideal_size[0] / $this->min_size[1], 0);185 $idealCropPx = $destCrop->width() - floor($destCrop->height() * $this->ideal_size[0] / $this->min_size[1]); 202 186 $maxCropPx = round($this->max_crop * $destCrop->width()); 203 $destCrop->crop_h( min($idealCropPx, $maxCropPx), $coi , false);187 $destCrop->crop_h( min($idealCropPx, $maxCropPx), $coi); 204 188 } 205 189 } … … 209 193 if ($w < $this->min_size[0]) 210 194 { 211 $idealCropPx = $destCrop->height() - round($destCrop->width() * $this->ideal_size[1] / $this->min_size[0], 0);195 $idealCropPx = $destCrop->height() - floor($destCrop->width() * $this->ideal_size[1] / $this->min_size[0]); 212 196 $maxCropPx = round($this->max_crop * $destCrop->height()); 213 $destCrop->crop_v( min($idealCropPx, $maxCropPx), $coi , false);197 $destCrop->crop_v( min($idealCropPx, $maxCropPx), $coi); 214 198 } 215 199 } … … 268 252 return array('last_mod_time', 'sizing', 'sharpen', 'quality'); 269 253 } 270 254 271 255 function add_url_tokens(&$tokens) 272 256 { … … 289 273 return $this->sizing->ideal_size[1]; 290 274 } 291 275 292 276 function is_identity($in_size) 293 277 {
Note: See TracChangeset
for help on using the changeset viewer.