当前位置: 首页>>代码示例>>PHP>>正文


PHP ImageInterface::rotate方法代码示例

本文整理汇总了PHP中Imagine\Image\ImageInterface::rotate方法的典型用法代码示例。如果您正苦于以下问题:PHP ImageInterface::rotate方法的具体用法?PHP ImageInterface::rotate怎么用?PHP ImageInterface::rotate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Imagine\Image\ImageInterface的用法示例。


在下文中一共展示了ImageInterface::rotate方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: transform

 public function transform(ImageInterface $image, ImagineInterface $imagine)
 {
     // Imagine comes with a built-in Autorotate filter, but it seems to be simpler to reimplement it
     // without bothering with the color.
     $metadata = $image->metadata();
     if (!isset($metadata['ifd0.Orientation'])) {
         return;
     }
     $orientation = $metadata['ifd0.Orientation'];
     if ($orientation == 3) {
         $image->rotate(180);
     } elseif ($orientation == 6) {
         $image->rotate(90);
     } elseif ($orientation == 8) {
         $image->rotate(-90);
     }
 }
开发者ID:phtamas,项目名称:yii2-imageprocessor,代码行数:17,代码来源:Autorotate.php

示例2: apply

 /**
  * {@inheritdoc}
  */
 public function apply(ImageInterface $image)
 {
     $metadata = $image->metadata();
     switch (isset($metadata['ifd0.Orientation']) ? $metadata['ifd0.Orientation'] : null) {
         case 3:
             $image->rotate(180, $this->getColor($image));
             break;
         case 6:
             $image->rotate(90, $this->getColor($image));
             break;
         case 8:
             $image->rotate(-90, $this->getColor($image));
             break;
         default:
             break;
     }
     return $image;
 }
开发者ID:ccq18,项目名称:EduSoho,代码行数:21,代码来源:Autorotate.php

示例3: apply

 /**
  * {@inheritdoc}
  */
 public function apply(ImageInterface $image)
 {
     $metadata = $image->metadata();
     switch (isset($metadata['ifd0.Orientation']) ? $metadata['ifd0.Orientation'] : null) {
         case 1:
             // top-left
             break;
         case 2:
             // top-right
             $image->flipHorizontally();
             break;
         case 3:
             // bottom-right
             $image->rotate(180, $this->getColor($image));
             break;
         case 4:
             // bottom-left
             $image->flipHorizontally();
             $image->rotate(180, $this->getColor($image));
             break;
         case 5:
             // left-top
             $image->flipHorizontally();
             $image->rotate(-90, $this->getColor($image));
             break;
         case 6:
             // right-top
             $image->rotate(90, $this->getColor($image));
             break;
         case 7:
             // right-bottom
             $image->flipHorizontally();
             $image->rotate(90, $this->getColor($image));
             break;
         case 8:
             // left-bottom
             $image->rotate(-90, $this->getColor($image));
             break;
         default:
             // Invalid orientation
             break;
     }
     return $image;
 }
开发者ID:sergiimazurok,项目名称:koziuck,代码行数:47,代码来源:Autorotate.php

示例4: preProcessSourceImg

 /**
  * @param ImageInterface $oldsource
  * @return ImageInterface
  */
 private function preProcessSourceImg(ImageInterface $source)
 {
     /** @var MetadataBag $metadata */
     $metadata = $source->metadata();
     $orientation = $metadata->offsetGet('ifd0.Orientation');
     switch ($orientation) {
         case 3:
             $source->rotate(180);
             break;
         case 6:
             $source->rotate(90);
             break;
         case 8:
             $source->rotate(-90);
             break;
         default:
             break;
     }
     $metadata->offsetSet('ifd0.Orientation', 1);
     return $source;
 }
开发者ID:vlatosev,项目名称:filebundle,代码行数:25,代码来源:ImageProcessor.php

示例5: rotate

	/**
	 * Rotate an image by degrees.
	 *
	 * @param int $degrees
	 *
	 * @return Image
	 */
	public function rotate($degrees)
	{
		$this->_image->rotate($degrees);

		return $this;
	}
开发者ID:harish94,项目名称:Craft-Release,代码行数:13,代码来源:Image.php

示例6: autoOrient

 /**
  * Re-orient an image using its embedded Exif profile orientation:
  * 1. Read the embedded exif data inside the image to determine it's orientation.
  * 2. Rotate and flip the image accordingly to re-orient it.
  * 3. Strip the Exif data from the image so that there can be no attempt to 'correct' it again.
  *
  * @param  string $path
  * @param  ImageInterface $image
  * @return ImageInterface $image
  */
 protected function autoOrient($path, ImageInterface $image)
 {
     $exif = exif_read_data($path);
     if (isset($exif['Orientation'])) {
         switch ($exif['Orientation']) {
             case 2:
                 $image->flipHorizontally();
                 break;
             case 3:
                 $image->rotate(180);
                 break;
             case 4:
                 $image->flipVertically();
                 break;
             case 5:
                 $image->flipVertically()->rotate(90);
                 break;
             case 6:
                 $image->rotate(90);
                 break;
             case 7:
                 $image->flipHorizontally()->rotate(90);
                 break;
             case 8:
                 $image->rotate(-90);
                 break;
         }
     }
     return $image->strip();
 }
开发者ID:JoelFieldCodeProjects,项目名称:test,代码行数:40,代码来源:Resizer.php

示例7: apply

 /**
  * {@inheritdoc}
  */
 public function apply(ImageInterface $image)
 {
     return $image->rotate($this->angle, $this->background);
 }
开发者ID:ccq18,项目名称:EduSoho,代码行数:7,代码来源:Rotate.php

示例8: filterRotate

 /**
  * Apply rotate filter
  *
  * @param  ImageInterface	$image An image instance
  * @param  float			$degree The rotation degree
  * @return void
  */
 protected function filterRotate(ImageInterface $image, $degree)
 {
     return $image->rotate($degree);
 }
开发者ID:sonjoysam,项目名称:laravel-image,代码行数:11,代码来源:ImageManager.php

示例9: correctExifRotation

 /**
  * @param \imagine\image\ImageInterface $image
  * @param string                        $filePath
  *
  * @return bool
  */
 protected function correctExifRotation($image, $filePath)
 {
     if (!function_exists('exif_read_data')) {
         return false;
     }
     $exif = @exif_read_data($filePath);
     if ($exif === false) {
         return false;
     }
     $orientation = (int) @$exif['Orientation'];
     if ($orientation < 2 || $orientation > 8) {
         return false;
     }
     switch ($orientation) {
         case 8:
             $image->rotate(-90);
             break;
         case 3:
             $image->rotate(180);
             break;
         case 6:
             $image->rotate(90);
             break;
     }
     return true;
 }
开发者ID:wozhen,项目名称:yii2-cms-writedown,代码行数:32,代码来源:MediaUploadHandler.php

示例10: load

 /**
  * Loads and applies a filter on the given image.
  *
  * @param ImageInterface $image
  * @param array          $options
  *
  * @return ManipulatorInterface
  */
 public function load(ImageInterface $image, array $options = array())
 {
     $angle = isset($options['angle']) ? (int) $options['angle'] : 0;
     return 0 === $angle ? $image : $image->rotate($angle);
 }
开发者ID:Tecnocreaciones,项目名称:ImagineService,代码行数:13,代码来源:RotateFilterLoader.php

示例11: applyRotateFilter

 /**
  * @param \Imagine\Image\ImageInterface $image
  * @param array $options
  * @return \Imagine\Image\ImageInterface
  */
 protected function applyRotateFilter(ImageInterface $image, $options)
 {
     if (isset($options['angle'])) {
         $angle = (int) $options['angle'];
         $image->rotate($angle);
     }
     return $image;
 }
开发者ID:getherbie,项目名称:plugin-imagine,代码行数:13,代码来源:ImagineExtension.php

示例12: autoOrient

 /**
  * Re-orient an image using its embedded Exif profile orientation:
  * 1. Attempt to read the embedded exif data inside the image to determine it's orientation.
  *    if there is no exif data (i.e an exeption is thrown when trying to read it) then we'll
  *    just return the image as is.
  * 2. If there is exif data, we'll rotate and flip the image accordingly to re-orient it.
  * 3. Finally, we'll strip the exif data from the image so that there can be no attempt to 'correct' it again.
  *
  * @param string         $path
  * @param ImageInterface $image
  *
  * @return ImageInterface $image
  */
 protected function autoOrient($path, ImageInterface $image)
 {
     if (function_exists('exif_read_data')) {
         try {
             $exif = exif_read_data($path);
         } catch (ErrorException $e) {
             return $image;
         }
         if (isset($exif['Orientation'])) {
             switch ($exif['Orientation']) {
                 case 2:
                     $image->flipHorizontally();
                     break;
                 case 3:
                     $image->rotate(180);
                     break;
                 case 4:
                     $image->flipVertically();
                     break;
                 case 5:
                     $image->flipVertically()->rotate(90);
                     break;
                 case 6:
                     $image->rotate(90);
                     break;
                 case 7:
                     $image->flipHorizontally()->rotate(90);
                     break;
                 case 8:
                     $image->rotate(-90);
                     break;
             }
         }
         return $image->strip();
     } else {
         return $image;
     }
 }
开发者ID:laravelian,项目名称:stapler,代码行数:51,代码来源:Resizer.php

示例13: rotate

 public function rotate(ImageInterface $image, $options = [])
 {
     $defaults = ['degrees' => 0];
     $options = array_merge($defaults, $options);
     $image->rotate($options['degrees']);
 }
开发者ID:grandfelix,项目名称:woodyattachments,代码行数:6,代码来源:UploadBehavior.php


注:本文中的Imagine\Image\ImageInterface::rotate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。