Changeset 13843 for trunk/admin


Ignore:
Timestamp:
Apr 1, 2012, 2:02:36 AM (12 years ago)
Author:
plg
Message:

feature 2604: support rotation on derivatives

Location:
trunk/admin/include
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/functions_upload.inc.php

    r13082 r13843  
    270270  }
    271271
     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 
    272277  $file_infos = pwg_image_infos($file_path);
    273278
     
    281286      'md5sum' => $md5sum,
    282287      'added_by' => $user['id'],
     288      'rotation' => $rotation,
    283289      );
    284290
     
    308314      'md5sum' => $md5sum,
    309315      'added_by' => $user['id'],
     316      'rotation' => $rotation,
    310317      );
    311318
  • trunk/admin/include/image.class.php

    r13736 r13843  
    239239    }
    240240
    241     $rotation = null;
     241    $rotation = 0;
    242242
    243243    $exif = exif_read_data($source_filepath);
     
    261261
    262262    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    }
    263285  }
    264286
     
    424446  {
    425447    $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)
    428453    {
    429454      $this->image->scaleImage($this->get_width()/2, $this->get_height()/2);
    430455    }
     456
    431457    return $this->image->resizeImage($width, $height, Imagick::FILTER_LANCZOS, 0.9);
    432458  }
Note: See TracChangeset for help on using the changeset viewer.