當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Image::crop方法代碼示例

本文整理匯總了PHP中Intervention\Image\Image::crop方法的典型用法代碼示例。如果您正苦於以下問題:PHP Image::crop方法的具體用法?PHP Image::crop怎麽用?PHP Image::crop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Intervention\Image\Image的用法示例。


在下文中一共展示了Image::crop方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: process

 public function process()
 {
     $data = $this->loadData();
     if ($data !== true) {
         return $this->failure($data);
     }
     $mobile = (int) $this->getProperty('mobile', 0);
     if ($mobile == 1) {
         $orientation = $this->img->exif('Orientation');
         switch ($orientation) {
             case 3:
                 $this->img->rotate(180);
                 break;
             case 6:
                 $this->img->rotate(-90);
                 break;
             case 8:
                 $this->img->rotate(90);
                 break;
         }
     }
     if (isset($this->data['rotate'])) {
         $rotate = $this->data['rotate'] * -1.0;
         $this->img->rotate($rotate);
     }
     $crop = $this->getProperty('crop', 0);
     if ($crop == 1 && isset($this->data['width']) && isset($this->data['height'])) {
         $width = intval($this->data['width']);
         $height = intval($this->data['height']);
         if ($height != 0 && $width != 0) {
             $this->img->crop($width, $height, intval($this->data['x']), intval($this->data['y']));
         }
     }
     $fileName = $this->generateUniqueFileName();
     $width = (int) $this->md->getOption('resizer.width', null, 0);
     $width = empty($width) ? null : $width;
     $height = (int) $this->md->getOption('resizer.height', null, 0);
     $height = empty($height) ? null : $height;
     $profileName = $this->getProperty('profile', '');
     if (!empty($profileName) && $crop == 1) {
         $profiles = $this->modx->fromJSON($this->md->getOption('cropper.profiles', null, '[]'));
         foreach ($profiles as $profile) {
             if (!isset($profile['name']) || $profile['name'] != $profileName) {
                 continue;
             }
             $profileWidth = (int) $profile['width'];
             $profileHeight = (int) $profile['height'];
             $width = empty($profileWidth) ? $width : $profileWidth;
             $height = empty($profileHeight) ? $height : $profileHeight;
             break;
         }
     }
     if ($width != null || $height != null) {
         $this->img->resize($width, $height, function ($constraint) {
             /** @var \Intervention\Image\Constraint $constraint */
             $constraint->aspectRatio();
             $constraint->upsize();
         });
     }
     $this->img->save($this->uploadPath . $fileName . '.' . $this->extension);
     return $this->success('', array('path' => $this->uploadURL . $fileName . '.' . $this->extension, 'name' => $this->originalName));
 }
開發者ID:ashliewebb,項目名稱:ashliewebb,代碼行數:62,代碼來源:imageupload.class.php

示例2: crop

 /**
  * Crop an image to the rectangle specified by the given rectangle.
  *
  * @param int $xoffset
  *   The top left coordinate, in pixels, of the crop area (x axis value).
  * @param int $yoffset
  *   The top left coordinate, in pixels, of the crop area (y axis value).
  * @param int $width
  *   The target width, in pixels.
  * @param int $height
  *   The target height, in pixels.
  *
  * @throws \LogicException if the parameters are wrong
  */
 public function crop($xoffset, $yoffset, $width, $height)
 {
     if ($xoffset === null) {
         throw new \LogicException('"xoffset" must not be null for "crop"');
     }
     if ($yoffset === null) {
         throw new \LogicException('"yoffset" must not be null for "crop"');
     }
     if ($width === null) {
         throw new \LogicException('"width" must not be null for "crop"');
     }
     if ($height === null) {
         throw new \LogicException('"height" must not be null for "crop"');
     }
     $this->image->crop($width, $height, $xoffset, $yoffset);
 }
開發者ID:onigoetz,項目名稱:imagecache,代碼行數:30,代碼來源:Image.php

示例3: rotation

 protected function rotation()
 {
     // Auto orientate
     $this->image->orientate();
     if ($this->flip) {
         $this->image->flip($this->flip);
     }
     // Rotate within the existing frame
     if ($this->rotation) {
         $width = $this->image->getWidth();
         $height = $this->image->getHeight();
         $this->image->rotate($this->rotation);
         $this->image->crop($width, $height);
     }
     // Rotate entire image
     if ($this->orientation) {
         $this->image->rotate($this->orientation);
     }
 }
開發者ID:Monori,項目名稱:imgback,代碼行數:19,代碼來源:ImageHandler.php

示例4: applyFilter

 /**
  * Applies filter to given image
  *
  * @param  Image $image
  * @return Image
  */
 public function applyFilter(Image $image)
 {
     return $image->crop((int) $this->with, (int) $this->height, (int) $this->x, (int) $this->y);
 }
開發者ID:parfumix,項目名稱:laravel-image-uploader,代碼行數:10,代碼來源:Crop.php

示例5: applyFilter

 public function applyFilter(Image $image)
 {
     return $image->crop($this->width, $this->height, $this->coordinatesX, $this->coordinatesY);
 }
開發者ID:draperstudio,項目名稱:laravel-picible,代碼行數:4,代碼來源:Crop.php

示例6: apply

 public function apply(Image $image)
 {
     $image->crop($this->width, $this->height);
 }
開發者ID:igaster,項目名稱:laravel-image-versions,代碼行數:4,代碼來源:Crop.php

示例7: crop

 public function crop($width, $height)
 {
     $this->image->crop($width, $height);
     return $this;
 }
開發者ID:bhutanio,項目名稱:laravel-utilities,代碼行數:5,代碼來源:Imager.php

示例8: crop

 /**
  * Crop the current image
  *
  * @param integer $width
  * @param integer $height
  * @param integer $pos_x
  * @param integer $pos_y
  * @return \Intervention\Image\Image 
  * @static 
  */
 public static function crop($width, $height, $pos_x = null, $pos_y = null)
 {
     return \Intervention\Image\Image::crop($width, $height, $pos_x, $pos_y);
 }
開發者ID:jorzhikgit,項目名稱:MLM-Nexus,代碼行數:14,代碼來源:_ide_helper.php

示例9: cropImage

 public function cropImage(ImageLayer $source, int $width, int $height, int $startX, int $startY) : ImageLayer
 {
     $source->crop($width, $height, $startX, $startY);
     return $source;
 }
開發者ID:cass-project,項目名稱:cass,代碼行數:5,代碼來源:FileAvatarStrategy.php

示例10: cropImage

 /**
  * Crop the image.
  *
  * @param integer $width
  * @param integer $height
  * @param integer|null $x
  * @param integer|null $y
  * @return $this
  */
 public function cropImage($width, $height, $x = null, $y = null)
 {
     $this->image->crop($width, $height, $x, $y);
     return $this;
 }
開發者ID:BePsvPT,項目名稱:CCU,代碼行數:14,代碼來源:ImageAbstract.php

示例11: handle

 /**
  * Handle the image manipulation request
  * @param  \Intervention\Image\Image $image
  * @param  array                     $options
  * @return mixed
  */
 public function handle($image, $options)
 {
     $options = array_merge($this->defaults, $options);
     return $image->crop($options['width'], $options['height'], $options['x'], $options['y']);
 }
開發者ID:Houbsi,項目名稱:Media,代碼行數:11,代碼來源:Crop.php

示例12: applyFilter

 /**
  * Applies filter effects to the given image
  *
  * @param Image\Image $image The image to filter.
  *
  * @return Image\Image The filtered image.
  */
 public function applyFilter(Image\Image $image)
 {
     return $image->crop($this->width, $this->height, $this->x, $this->y);
 }
開發者ID:BitmanNL,項目名稱:traffictower-cms,代碼行數:11,代碼來源:CropFilter.php

示例13: process

 public function process(Image $image)
 {
     if ($this->request->query->has('crop') && !$this->request->query->has('width') && !$this->request->query->has('height') && 1 === preg_match('#^([0-9]+)[x\\:]([0-9]+)$#', $this->request->query->get('crop'), $crop)) {
         $image->crop($crop[1], $crop[2]);
     }
 }
開發者ID:ambroisemaupate,項目名稱:intervention-request,代碼行數:6,代碼來源:CropProcessor.php


注:本文中的Intervention\Image\Image::crop方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。