Changeset 13843
- Timestamp:
- Apr 1, 2012, 2:02:36 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/include/functions_upload.inc.php
r13082 r13843 270 270 } 271 271 272 // we need to save the rotation angle in the database to compute 273 // width/height of "multisizes" 274 $rotation_angle = pwg_image::get_rotation_angle($file_path); 275 $rotation = pwg_image::get_rotation_code_from_angle($rotation_angle); 276 272 277 $file_infos = pwg_image_infos($file_path); 273 278 … … 281 286 'md5sum' => $md5sum, 282 287 'added_by' => $user['id'], 288 'rotation' => $rotation, 283 289 ); 284 290 … … 308 314 'md5sum' => $md5sum, 309 315 'added_by' => $user['id'], 316 'rotation' => $rotation, 310 317 ); 311 318 -
trunk/admin/include/image.class.php
r13736 r13843 239 239 } 240 240 241 $rotation = null;241 $rotation = 0; 242 242 243 243 $exif = exif_read_data($source_filepath); … … 261 261 262 262 return $rotation; 263 } 264 265 static function get_rotation_code_from_angle($rotation_angle) 266 { 267 switch($rotation_angle) 268 { 269 case 0: return 0; 270 case 90: return 1; 271 case 180: return 2; 272 case 270: return 3; 273 } 274 } 275 276 static function get_rotation_angle_from_code($rotation_code) 277 { 278 switch($rotation_code) 279 { 280 case 0: return 0; 281 case 1: return 90; 282 case 2: return 180; 283 case 3: return 270; 284 } 263 285 } 264 286 … … 424 446 { 425 447 $this->image->setInterlaceScheme(Imagick::INTERLACE_LINE); 426 if ($this->get_width()%2 == 0 && $this->get_height()%2 == 0 427 && $this->get_width() > 3*$width) 448 449 // TODO need to explain this condition 450 if ($this->get_width()%2 == 0 451 && $this->get_height()%2 == 0 452 && $this->get_width() > 3*$width) 428 453 { 429 454 $this->image->scaleImage($this->get_width()/2, $this->get_height()/2); 430 455 } 456 431 457 return $this->image->resizeImage($width, $height, Imagick::FILTER_LANCZOS, 0.9); 432 458 } -
trunk/i.php
r13736 r13843 445 445 try 446 446 { 447 $query = 'SELECT coi, width, height FROM '.$prefixeTable.'images WHERE path=\''.$page['src_location'].'\''; 447 $query = ' 448 SELECT 449 id, 450 coi, 451 width, 452 height, 453 rotation 454 FROM '.$prefixeTable.'images 455 WHERE path=\''.$page['src_location'].'\' 456 ;'; 457 448 458 if ( ($row=pwg_db_fetch_assoc(pwg_query($query))) ) 449 459 { … … 453 463 } 454 464 $page['coi'] = $row['coi']; 465 466 include_once(PHPWG_ROOT_PATH . 'admin/include/image.class.php'); 467 468 if (empty($row['rotation'])) 469 { 470 $page['rotation_angle'] = pwg_image::get_rotation_angle($page['src_path']); 471 472 single_update( 473 $prefixeTable.'images', 474 array('rotation' => pwg_image::get_rotation_code_from_angle($page['rotation_angle'])), 475 array('id' => $row['id']) 476 ); 477 } 478 else 479 { 480 $page['rotation_angle'] = pwg_image::get_rotation_angle_from_code($row['rotation']); 481 } 482 455 483 } 456 484 if (!$row) … … 472 500 ierror("dir create error", 500); 473 501 } 474 475 include_once(PHPWG_ROOT_PATH . 'admin/include/image.class.php');476 502 477 503 ignore_user_abort(true); … … 483 509 $changes = 0; 484 510 485 // todo rotate 511 // rotate 512 if (0 != $page['rotation_angle']) 513 { 514 $image->rotate($page['rotation_angle']); 515 } 486 516 487 517 // Crop & scale … … 555 585 $image->strip(); 556 586 } 587 557 588 $image->set_compression_quality( $params->quality ); 558 589 $image->write( $page['derivative_path'] ); -
trunk/include/dblayer/functions_mysql.inc.php
r13038 r13843 371 371 $separator = $is_first ? '' : ",\n "; 372 372 373 if (isset($value) and $value != '')373 if (isset($value) and $value !== '') 374 374 { 375 375 $query.= $separator.$key.' = \''.$value.'\''; -
trunk/include/derivative.inc.php
r13489 r13843 56 56 if (!$this->size && isset($infos['width']) && isset($infos['height'])) 57 57 { 58 $this->size = array($infos['width'], $infos['height']); 58 $width = $infos['width']; 59 $height = $infos['height']; 60 61 // 1 or 5 => 90 clockwise 62 // 3 or 7 => 270 clockwise 63 if ($infos['rotation'] % 2 != 0) 64 { 65 $width = $infos['height']; 66 $height = $infos['width']; 67 } 68 69 $this->size = array($width, $height); 59 70 } 60 71 }
Note: See TracChangeset
for help on using the changeset viewer.