コード例 #1
0
ファイル: ImageMedium.php プロジェクト: emac/emacoo.cn
 /**
  * Add a derivative
  *
  * @param  ImageMedium $image
  */
 public function addDerivative(ImageMedium $image)
 {
     $this->derivatives[$image->url()] = $image->get('width');
 }
コード例 #2
0
ファイル: MediumFactory.php プロジェクト: rdquintas/Alphalink
 /**
  * Create a new ImageMedium by scaling another ImageMedium object.
  *
  * @param  ImageMedium $medium
  * @param  int         $from
  * @param  int         $to
  * @return Medium
  */
 public static function scaledFromMedium($medium, $from, $to)
 {
     if (!$medium instanceof ImageMedium) {
         return $medium;
     }
     if ($to > $from) {
         return $medium;
     }
     $ratio = $to / $from;
     $width = (int) ($medium->get('width') * $ratio);
     $height = (int) ($medium->get('height') * $ratio);
     $basename = $medium->get('basename');
     $basename = str_replace('@' . $from . 'x', '@' . $to . 'x', $basename);
     $debug = $medium->get('debug');
     $medium->set('debug', false);
     $file = $medium->resize($width, $height)->path();
     $medium->set('debug', $debug);
     $size = filesize($file);
     $medium = self::fromFile($file);
     $medium->set('size', $size);
     return ['file' => $medium, 'size' => $size];
 }