コード例 #1
0
 public function resize($width, $height, $upscale = false)
 {
     if ($upscale === false && ($width >= $this->image_class->get_width() || $height >= $this->image_class->get_height())) {
         return $this;
     }
     $this->image_class->resize($width, $height);
     return $this;
 }
コード例 #2
0
ファイル: Image.php プロジェクト: ejailesb/repo
 /**
  * @return SimpleImage
  */
 protected function create()
 {
     $image = new SimpleImage($this->file);
     switch ($this->options['strategy']) {
         case 'thumbnail':
             $width = $this->options['w'] ?: $image->get_width();
             $height = $this->options['h'] ?: $image->get_height();
             $image->resize($width, $height);
             break;
         case 'best_fit':
             $width = $this->options['w'] ?: $image->get_width();
             $height = $this->options['h'] ?: $image->get_height();
             if (is_numeric($width) && is_numeric($height)) {
                 $image->best_fit($width, $height);
             }
             break;
         default:
             $width = $this->options['w'];
             $height = $this->options['h'];
             if (is_numeric($width) && is_numeric($height)) {
                 $image->thumbnail($width, $height);
             } elseif (is_numeric($width)) {
                 $image->fit_to_width($width);
             } elseif (is_numeric($height)) {
                 $image->fit_to_height($height);
             } else {
                 $width = $image->get_width();
                 $height = $image->get_height();
                 $image->thumbnail($width, $height);
             }
     }
     return $image;
 }
コード例 #3
0
ファイル: ImageModel.php プロジェクト: hansm/ImageTool
 /**
  * Resize image
  *
  * @param string $imagePath
  * @param int $width
  * @param int $height
  * @throws \ImageTool\Model\ModelException
  */
 public function resize($imagePath, $width, $height)
 {
     try {
         $simpleImage = new SimpleImage($imagePath);
         $simpleImage->resize($width, $height)->save();
     } catch (Exception $e) {
         Log::get()->error('Failed to resize image.', $e);
         throw new ModelException('Failed to resize image.');
     }
 }
コード例 #4
0
ファイル: Image.php プロジェクト: ejailesb/repo_empr
 /**
  * @return SimpleImage
  */
 protected function create()
 {
     $image = new SimpleImage($this->file);
     $width = $this->options['w'] ?: $image->get_width();
     $height = $this->options['h'] ?: $image->get_height();
     switch ($this->options['strategy']) {
         case 'thumbnail':
             $image->resize($width, $height);
             break;
         case 'best_fit':
             $image->best_fit($width, $height);
             break;
         default:
             $image->thumbnail($width, $height);
     }
     return $image;
 }