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


PHP Image\ImageInterface类代码示例

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


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

示例1: cropImage

 /**
  * Crop image if exceeds boundaries
  *
  * @param ImageInterface $image
  * @param $settings
  * @return ImageInterface
  */
 private function cropImage(ImageInterface $image, $settings)
 {
     $neededSize = new Box($settings['width'], $settings['height']);
     $currentSize = $image->getSize();
     if ($neededSize->contains($currentSize)) {
         return $image;
     }
     $point = new Point($currentSize->getWidth() > $neededSize->getWidth() ? round(($currentSize->getWidth() - $neededSize->getWidth()) / 2) : 0, $currentSize->getHeight() > $neededSize->getHeight() ? round(($currentSize->getHeight() - $neededSize->getHeight()) / 2) : 0);
     $image->crop($point, $neededSize);
     return $image;
 }
开发者ID:xaben,项目名称:XabenMediaBundle,代码行数:18,代码来源:OutboundResizer.php

示例2: load

 /**
  * {@inheritDoc}
  */
 public function load(ImageInterface $image, array $options = array())
 {
     $background = new Color(isset($options['color']) ? $options['color'] : '#fff');
     $topLeft = new Point(0, 0);
     $canvas = $this->imagine->create($image->getSize(), $background);
     return $canvas->paste($image, $topLeft);
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:10,代码来源:BackgroundFilterLoader.php

示例3: load

    /**
     * {@inheritDoc}
     */
    public function load(ImageInterface $image, array $options = array())
    {
        if (!isset($options['min'])) {
            throw new \InvalidArgumentException('Missing min option.');
        }

        list($width, $height) = $options['min'];

        $size = $image->getSize();
        $origWidth = $size->getWidth();
        $origHeight = $size->getHeight();

        if ($origWidth < $width || $origHeight < $height) {
            $widthRatio = $width / $origWidth;
            $heightRatio = $height / $origHeight;

            $ratio = $widthRatio > $heightRatio ? $widthRatio : $heightRatio;

            $filter = new Resize(new Box($origWidth * $ratio, $origHeight * $ratio));

            return $filter->apply($image);
        }

        return $image;
    }
开发者ID:networksoft,项目名称:seekerplus.com,代码行数:28,代码来源:UpscaleFilterLoader.php

示例4: getColor

 private function getColor(ImageInterface $image)
 {
     if ($this->color instanceof ColorInterface) {
         return $this->color;
     }
     return $image->palette()->color($this->color);
 }
开发者ID:ccq18,项目名称:EduSoho,代码行数:7,代码来源:Autorotate.php

示例5: apply

 /**
  * @param ImageInterface|\Imagine\Gmagick\Image $image
  *
  * @return ImageInterface
  */
 public function apply(ImageInterface $image)
 {
     /** @var \Gmagick $gmagick */
     $gmagick = $image->getGmagick();
     $gmagick->reduceNoiseImage((double) $this->getOption('radius', 0));
     return $image;
 }
开发者ID:Heyfara,项目名称:ezpublish-kernel,代码行数:12,代码来源:ReduceNoiseFilter.php

示例6: load

 /**
  * {@inheritdoc}
  */
 public function load(ImageInterface $image, array $options = array())
 {
     $mode = ImageInterface::THUMBNAIL_OUTBOUND;
     if (!empty($options['mode']) && 'inset' === $options['mode']) {
         $mode = ImageInterface::THUMBNAIL_INSET;
     }
     if (!empty($options['filter'])) {
         $filter = constant('Imagine\\Image\\ImageInterface::FILTER_' . strtoupper($options['filter']));
     }
     if (empty($filter)) {
         $filter = ImageInterface::FILTER_UNDEFINED;
     }
     list($width, $height) = $options['size'];
     $size = $image->getSize();
     $origWidth = $size->getWidth();
     $origHeight = $size->getHeight();
     if (null === $width || null === $height) {
         if (null === $height) {
             $height = (int) ($width / $origWidth * $origHeight);
         } elseif (null === $width) {
             $width = (int) ($height / $origHeight * $origWidth);
         }
     }
     if ($origWidth > $width || $origHeight > $height || !empty($options['allow_upscale']) && ($origWidth !== $width || $origHeight !== $height)) {
         $filter = new Thumbnail(new Box($width, $height), $mode, $filter);
         $image = $filter->apply($image);
     }
     return $image;
 }
开发者ID:raphydev,项目名称:onep,代码行数:32,代码来源:ThumbnailFilterLoader.php

示例7: apply

 /**
  * {@inheritdoc}
  */
 public function apply(ImageInterface $image)
 {
     $currentSize = $image->getSize();
     $ratioCurrent = $currentSize->getHeight() / $currentSize->getWidth();
     $ratioNew = $this->size->getHeight() / $this->size->getWidth();
     // ratio inverse of original and thumb image
     $ratioInverseNew = 1 / $ratioNew;
     // image has to crop
     if ($ratioCurrent != $ratioNew) {
         if ($this->size->getWidth() > $this->size->getHeight()) {
             $cropHeight = $currentSize->getWidth() * $ratioNew;
             $cropWidth = $currentSize->getWidth();
             if ($cropHeight > $currentSize->getHeight()) {
                 $correction = 1 / ($cropHeight / $currentSize->getHeight());
                 $cropWidth *= $correction;
                 $cropHeight *= $correction;
             }
         } else {
             $cropWidth = $currentSize->getHeight() * $ratioInverseNew;
             $cropHeight = $currentSize->getHeight();
             if ($cropWidth > $currentSize->getWidth()) {
                 $correction = 1 / ($cropWidth / $currentSize->getWidth());
                 $cropWidth *= $correction;
                 $cropHeight *= $correction;
             }
         }
         $cropSize = new Box($cropWidth, $cropHeight);
         $startPoint = $this->gravity->getStartPoint($cropSize);
         $image = $image->crop($startPoint, $cropSize);
     }
     return $image->resize($this->size);
 }
开发者ID:shapecode,项目名称:imagine-thumbnail-gravity-filter,代码行数:35,代码来源:ThumbnailGravity.php

示例8: createFromImagine

 /**
  * @param ImageInterface $image
  * @param $namespace
  * @param $image_hash
  * @param $image_thumb
  * @return File
  */
 public function createFromImagine(ImageInterface $image, $namespace, $image_hash, $image_thumb)
 {
     umask(00);
     $dest = $this->createDestinationPath($namespace, $image_hash, $image_thumb);
     $image->save($dest);
     return new File($dest);
 }
开发者ID:vlatosev,项目名称:filebundle,代码行数:14,代码来源:ImageCacheManager.php

示例9: generateThumb

 /**
  * @param ImageInterface $image
  * @return ImageInterface
  */
 public function generateThumb(ImageInterface $image, $width, $height)
 {
     $background = isset($this->options["background"]) ? $this->options["background"] : null;
     $fitSize = isset($this->options["fitSize"]) ? $this->options["fitSize"] : true;
     $sizeBox = new Box($width, $height);
     $thumbMode = ImageInterface::THUMBNAIL_INSET;
     $thumb = $image->thumbnail($sizeBox, $thumbMode);
     // fill the area
     if ($fitSize) {
         $palette = new RGB();
         if (!$background || $background == "transparent") {
             $backgroundColor = $palette->color("fff", 1);
         } else {
             $backgroundColor = $palette->color($background);
         }
         // source http://harikt.com/blog/2012/12/17/resize-image-keeping-aspect-ratio-in-imagine/
         $realThumb = Image::create($sizeBox, $backgroundColor);
         $sizeR = $thumb->getSize();
         $widthR = $sizeR->getWidth();
         $heightR = $sizeR->getHeight();
         $startX = $startY = 0;
         if ($widthR < $width) {
             $startX = ($width - $widthR) / 2;
         }
         if ($heightR < $height) {
             $startY = ($height - $heightR) / 2;
         }
         $realThumb->paste($thumb, new Point($startX, $startY));
     } else {
         $realThumb = $thumb;
     }
     return $realThumb;
 }
开发者ID:gsouf,项目名称:thumbz,代码行数:37,代码来源:ThumbMaker.php

示例10: apply

 /**
  * @param ImageInterface|\Imagine\Gmagick\Image $image
  *
  * @return ImageInterface
  */
 public function apply(ImageInterface $image)
 {
     /** @var \Gmagick $gmagick */
     $gmagick = $image->getGmagick();
     $gmagick->swirlimage((double) $this->getOption('degrees', 60));
     return $image;
 }
开发者ID:CG77,项目名称:ezpublish-kernel,代码行数:12,代码来源:SwirlFilter.php

示例11: createCache

 /**
  * {@inheritDoc}
  */
 public function createCache($relativeName, $filter, ImageInterface $image, $formatOrImage = null, array $saveOptions = [])
 {
     $cachePath = $this->getCachePath($relativeName, $filter, $formatOrImage);
     if (!is_dir(dirname($cachePath))) {
         mkdir(dirname($cachePath), 0755, true);
     }
     $image->save($cachePath, $saveOptions);
 }
开发者ID:shitikovkirill,项目名称:zend-shop.com,代码行数:11,代码来源:CacheManager.php

示例12: load

 public function load(ImageInterface $image, array $options = array())
 {
     if (empty($options)) {
         throw new InvalidArgumentException('Missing width option');
     }
     $filter = new Gravity(new Box((int) $options[0], (int) $options[1]), new MiddleMiddle($image->getSize()));
     $image = $filter->apply($image);
     return $image;
 }
开发者ID:eab-dev,项目名称:EabImageFilterBundle,代码行数:9,代码来源:ThumbnailGravityCenterFilterLoader.php

示例13: apply

 /**
  * Applies scheduled transformation to ImageInterface instance
  * Returns processed ImageInterface instance
  *
  * @param ImageInterface $image
  *
  * @return ImageInterface
  */
 public function apply(ImageInterface $image)
 {
     for ($x = 0; $x < $image->getSize()->getWidth(); $x++) {
         for ($y = 0; $y < $image->getSize()->getHeight(); $y++) {
             call_user_func($this->callback, $image, new Point($x, $y));
         }
     }
     return $image;
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:17,代码来源:OnPixelBased.php

示例14: load

 /**
  * {@inheritdoc}
  */
 public function load(ImageInterface $image, array $options = array())
 {
     $mode = ImageInterface::INTERLACE_LINE;
     if (!empty($options['mode'])) {
         $mode = $options['mode'];
     }
     $image->interlace($mode);
     return $image;
 }
开发者ID:raphydev,项目名称:onep,代码行数:12,代码来源:InterlaceFilterLoader.php

示例15: pasteCentered

 protected function pasteCentered(\Imagine\Image\ImageInterface $image, \Imagine\Image\ImageInterface $original)
 {
     $originalSize = $original->getSize();
     $x = $this->getPasteValue($this->size->getWidth(), $originalSize->getWidth());
     $y = $this->getPasteValue($this->size->getHeight(), $originalSize->getHeight());
     $pastePoint = new \Imagine\Image\Point($x, $y);
     $image->paste($original, $pastePoint);
     return $image;
 }
开发者ID:rtablada,项目名称:resize-and-pad,代码行数:9,代码来源:ResizeAndPad.php


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