• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Image\ImageInterface类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: apply

 /**
  * {@inheritDoc}
  */
 public function apply(ImageInterface $image)
 {
     $watermark = $this->watermark;
     $size = $image->getSize();
     $watermarkSize = $watermark->getSize();
     // If 'null': Downscale if needed
     if (!$this->size && ($size->getWidth() < $watermarkSize->getWidth() || $size->getHeight() < $watermarkSize->getHeight())) {
         $this->size = 1.0;
     }
     if ($this->size) {
         $factor = $this->size * min($size->getWidth() / $watermarkSize->getWidth(), $size->getHeight() / $watermarkSize->getHeight());
         $watermark->resize(new Box($watermarkSize->getWidth() * $factor, $watermarkSize->getHeight() * $factor));
         $watermarkSize = $watermark->getSize();
     }
     switch ($this->position) {
         case 'topleft':
             $x = 0;
             $y = 0;
             break;
         case 'top':
             $x = ($size->getWidth() - $watermarkSize->getWidth()) / 2;
             $y = 0;
             break;
         case 'topright':
             $x = $size->getWidth() - $watermarkSize->getWidth();
             $y = 0;
             break;
         case 'left':
             $x = 0;
             $y = ($size->getHeight() - $watermarkSize->getHeight()) / 2;
             break;
         case 'center':
             $x = ($size->getWidth() - $watermarkSize->getWidth()) / 2;
             $y = ($size->getHeight() - $watermarkSize->getHeight()) / 2;
             break;
         case 'right':
             $x = $size->getWidth() - $watermarkSize->getWidth();
             $y = ($size->getHeight() - $watermarkSize->getHeight()) / 2;
             break;
         case 'bottomleft':
             $x = 0;
             $y = $size->getHeight() - $watermarkSize->getHeight();
             break;
         case 'bottom':
             $x = ($size->getWidth() - $watermarkSize->getWidth()) / 2;
             $y = $size->getHeight() - $watermarkSize->getHeight();
             break;
         case 'bottomright':
             $x = $size->getWidth() - $watermarkSize->getWidth();
             $y = $size->getHeight() - $watermarkSize->getHeight();
             break;
         default:
             throw new Exception\InvalidArgumentException(sprintf('Unknown position "%s"', $this->position));
     }
     return $image->paste($watermark, new Point($x, $y));
 }
开发者ID:shitikovkirill,项目名称:zend-shop.com,代码行数:59,代码来源:Watermark.php


示例17: stringYtoInteger

 /**
  * @param string                        $point
  * @param \Imagine\Image\ImageInterface $pasteImage
  * @param \Imagine\Image\ImageInterface $image
  *
  * @return integer
  */
 protected function stringYtoInteger($point, ImageInterface $pasteImage, ImageInterface $image)
 {
     switch ($point) {
         case 'bottom':
             return (int) $image->getSize()->getHeight() - $pasteImage->getSize()->getHeight();
         case 'middle':
             return (int) round($image->getSize()->getHeight() / 2 - $pasteImage->getSize()->getHeight() / 2);
         case 'top':
     }
 }
开发者ID:shitikovkirill,项目名称:zend-shop.com,代码行数:17,代码来源:Paste.php


示例18: execute

 /**
  * {@inheritdoc}
  */
 public function execute(ImageInterface &$image, $parameters)
 {
     $retina = isset($parameters['retina']) && $parameters['retina'] != 'false' ? 2 : 1;
     $x = isset($parameters['x']) ? intval($parameters['x']) * $retina : 0;
     $y = isset($parameters['y']) ? intval($parameters['y']) * $retina : 0;
     $width = isset($parameters['w']) ? intval($parameters['w']) : 0;
     $height = isset($parameters['h']) ? intval($parameters['h']) : 0;
     $point = new Point($x, $y);
     $box = new Box($width, $height);
     $image->crop($point, $box);
 }
开发者ID:Silwereth,项目名称:sulu,代码行数:14,代码来源:CropCommand.php


示例19: performResize

 /**
  * Performs resize of the image. Imagine component is used.
  *
  * @param ImageInterface $imagine
  * @param                $resize
  * @param bool           $crop
  *
  * @return BoxInterface
  */
 private function performResize($imagine, $resize, $crop = true)
 {
     $box = $imagine->getSize();
     list($width, $height) = Utils::getDimension($resize);
     $box = $box->scale(max($width / $box->getWidth(), $height / $box->getHeight()));
     $imagine->resize($box);
     if ($crop) {
         $point = new Point(($box->getWidth() - $width) / 2, ($box->getHeight() - $height) / 2);
         $imagine->crop($point, new Box($width, $height));
     }
     return $box;
 }
开发者ID:voodoo-mobile,项目名称:yii2-image,代码行数:21,代码来源:UploadedImage.php


示例20: apply

 public function apply(ImageInterface &$image, ImagineInterface $imagine)
 {
     $box = $image->getSize();
     $width = Helper::percentValue($this->_width, $box->getWidth());
     $height = Helper::percentValue($this->_height, $box->getHeight());
     // no upscale
     if ($box->getWidth() <= $width && $box->getHeight() <= $height) {
         return;
     }
     Helper::scaleSize($width, $height, $box);
     $image->resize(new Box($width, $height));
 }
开发者ID:x000000,项目名称:storage-manager,代码行数:12,代码来源:Resize.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Image\ImagineInterface类代码示例发布时间:2022-05-23
下一篇:
PHP Image\BoxInterface类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap