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


PHP ImageInterface::palette方法代码示例

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


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

示例1: 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

示例2: imageColorize

 /**
  * Command image colorize
  * 
  * @param string $hexColor
  * 
  * @return void
  */
 protected function imageColorize($hexColor)
 {
     if (strlen($hexColor) != 6 || !preg_match('![0-9abcdef]!i', $hexColor)) {
         throw new BadMethodCallException('Invalid parameter color for command "colorize"');
     }
     $color = $this->image->palette()->color('#' . $hexColor);
     $this->image->effects()->colorize($color);
 }
开发者ID:dgram,项目名称:zf2-imageresizer,代码行数:15,代码来源:ImageProcessing.php

示例3: load

 /**
  * {@inheritdoc}
  */
 public function load(ImageInterface $image, array $options = array())
 {
     $background = $image->palette()->color(isset($options['color']) ? $options['color'] : '#fff', isset($options['transparency']) ? $options['transparency'] : null);
     $topLeft = new Point(0, 0);
     $size = $image->getSize();
     if (isset($options['size'])) {
         list($width, $height) = $options['size'];
         $position = isset($options['position']) ? $options['position'] : 'center';
         switch ($position) {
             case 'topleft':
                 $x = 0;
                 $y = 0;
                 break;
             case 'top':
                 $x = ($width - $image->getSize()->getWidth()) / 2;
                 $y = 0;
                 break;
             case 'topright':
                 $x = $width - $image->getSize()->getWidth();
                 $y = 0;
                 break;
             case 'left':
                 $x = 0;
                 $y = ($height - $image->getSize()->getHeight()) / 2;
                 break;
             case 'center':
                 $x = ($width - $image->getSize()->getWidth()) / 2;
                 $y = ($height - $image->getSize()->getHeight()) / 2;
                 break;
             case 'right':
                 $x = $width - $image->getSize()->getWidth();
                 $y = ($height - $image->getSize()->getHeight()) / 2;
                 break;
             case 'bottomleft':
                 $x = 0;
                 $y = $height - $image->getSize()->getHeight();
                 break;
             case 'bottom':
                 $x = ($width - $image->getSize()->getWidth()) / 2;
                 $y = $height - $image->getSize()->getHeight();
                 break;
             case 'bottomright':
                 $x = $width - $image->getSize()->getWidth();
                 $y = $height - $image->getSize()->getHeight();
                 break;
             default:
                 throw new \InvalidArgumentException("Unexpected position '{$position}'");
                 break;
         }
         $size = new Box($width, $height);
         $topLeft = new Point($x, $y);
     }
     $canvas = $this->imagine->create($size, $background);
     return $canvas->paste($image, $topLeft);
 }
开发者ID:aminin,项目名称:LiipImagineBundle,代码行数:58,代码来源:BackgroundFilterLoader.php

示例4: load

 /**
  * {@inheritDoc}
  */
 public function load(ImageInterface $image, array $options = array())
 {
     $background = $image->palette()->color(isset($options['color']) ? $options['color'] : '#fff', isset($options['transparency']) ? $options['transparency'] : null);
     $topLeft = new Point(0, 0);
     $size = $image->getSize();
     if (isset($options['size'])) {
         list($width, $height) = $options['size'];
         $size = new Box($width, $height);
         $topLeft = new Point(($width - $image->getSize()->getWidth()) / 2, ($height - $image->getSize()->getHeight()) / 2);
     }
     $canvas = $this->imagine->create($size, $background);
     return $canvas->paste($image, $topLeft);
 }
开发者ID:sanchojaf,项目名称:oldmytriptocuba,代码行数:16,代码来源:BackgroundFilterLoader.php

示例5: apply

 /**
  * {@inheritDoc}
  */
 public function apply(ImageInterface $image)
 {
     if ($this->size) {
         list($width, $height) = $this->size;
         $size = new Box($width, $height);
         $topLeft = new Point(($width - $image->getSize()->getWidth()) / 2, ($height - $image->getSize()->getHeight()) / 2);
     } else {
         $topLeft = new Point(0, 0);
         $size = $image->getSize();
     }
     $background = $image->palette()->color($this->color);
     $canvas = $this->imagine->create($size, $background);
     return $canvas->paste($image, $topLeft);
 }
开发者ID:shitikovkirill,项目名称:zend-shop.com,代码行数:17,代码来源:Background.php

示例6: load

 public function load(ImageInterface $image, array $options = array())
 {
     $optionsCount = count($options);
     if ($optionsCount < 2) {
         throw new InvalidArgumentException('Invalid options for border filter. You must provide array(width, height)');
     }
     $color = static::DEFAULT_BORDER_COLOR;
     if ($optionsCount > 2) {
         list($width, $height, $color) = $options;
     } else {
         list($width, $height) = $options;
     }
     $border = new Border($image->palette()->color($color), $width, $height);
     return $border->apply($image);
 }
开发者ID:CG77,项目名称:ezpublish-kernel,代码行数:15,代码来源:BorderFilterLoader.php

示例7: drawCenteredText

 /**
  * Draw centered text in current image
  * 
  * @param string $text
  * @param string $color
  * 
  * @return void
  */
 protected function drawCenteredText($text, $color)
 {
     $width = $this->image->getSize()->getWidth();
     $height = $this->image->getSize()->getHeight();
     $fontColor = $this->image->palette()->color('#' . $color);
     $fontSize = 48;
     $widthFactor = $width > 160 ? 0.8 : 0.9;
     $heightFactor = $height > 160 ? 0.8 : 0.9;
     do {
         $font = $this->getImagineService()->font(__DIR__ . '/../../../data/font/Roboto-Regular.ttf', $fontSize, $fontColor);
         $fontBox = $font->box($text);
         $fontSize = round($fontSize * 0.8);
     } while ($fontSize > 5 && ($width * $widthFactor < $fontBox->getWidth() || $height * $heightFactor < $fontBox->getHeight()));
     $pointX = max(0, floor(($width - $fontBox->getWidth()) / 2));
     $pointY = max(0, floor(($height - $fontBox->getHeight()) / 2));
     $this->image->draw()->text($text, $font, new Point($pointX, $pointY));
 }
开发者ID:tck,项目名称:zf2-imageresizer,代码行数:25,代码来源:ImageProcessing.php

示例8: applyEffect

 /**
  * Применяет эффект к изображению.
  * @param ImageInterface $Image
  * @param string $effect
  * @param string $additional
  * @return bool
  */
 private function applyEffect(ImageInterface $Image, $effect, $additional = null)
 {
     switch ($effect) {
         case 'resize':
             if (!isset($additional['width']) || !isset($additional['height'])) {
                 return false;
             }
             $Image->resize(new Box($additional['width'], $additional['height']));
             break;
         case 'origin':
             break;
         case 'negative':
             $Image->effects()->negative();
             break;
         case 'grayscale':
             $Image->effects()->grayscale();
             break;
         case 'sharpen':
             $Image->effects()->sharpen();
             break;
         case 'colorize':
             $Image->effects()->colorize($Image->palette()->color($additional));
             break;
         case 'gamma':
             $Image->effects()->gamma($additional);
             break;
         case 'blur':
             $Image->effects()->blur($additional);
             break;
         default:
             return false;
     }
     return true;
 }
开发者ID:andrei2nikitin,项目名称:quiz,代码行数:41,代码来源:MainPage.php

示例9: resize

 /**
  * Executes the actual resizing operation on the Imagine image.
  * In case of an outbound resize the image will be resized and cropped.
  *
  * @param ImagineImageInterface $image
  * @param string $mode
  * @param string $filter
  * @return \Imagine\Image\ManipulatorInterface
  */
 protected function resize(ImagineImageInterface $image, $mode = ImageInterface::RATIOMODE_INSET, $filter = ImagineImageInterface::FILTER_UNDEFINED)
 {
     if ($mode !== ImageInterface::RATIOMODE_INSET && $mode !== ImageInterface::RATIOMODE_OUTBOUND) {
         throw new \InvalidArgumentException('Invalid mode specified');
     }
     $imageSize = $image->getSize();
     $requestedDimensions = $this->calculateDimensions($imageSize);
     $resizedImage = $image->copy();
     $resizedImage->usePalette($image->palette());
     $resizedImage->strip();
     $resizeDimensions = $requestedDimensions;
     if ($mode === ImageInterface::RATIOMODE_OUTBOUND) {
         $resizeDimensions = $this->calculateOutboundScalingDimensions($imageSize, $requestedDimensions);
     }
     $resizedImage->resize($resizeDimensions, $filter);
     if ($mode === ImageInterface::RATIOMODE_OUTBOUND) {
         $resizedImage->crop(new Point(max(0, round(($resizeDimensions->getWidth() - $requestedDimensions->getWidth()) / 2)), max(0, round(($resizeDimensions->getHeight() - $requestedDimensions->getHeight()) / 2))), $requestedDimensions);
     }
     return $resizedImage;
 }
开发者ID:netlogix,项目名称:media,代码行数:29,代码来源:ResizeImageAdjustment.php

示例10: filterColorize

 /**
  * Apply colorize filter
  *
  * @param  ImageInterface	$image An image instance
  * @param  string			$color The hex value of the color
  * @return void
  */
 protected function filterColorize(ImageInterface $image, $color)
 {
     $color = $image->palette()->color($color);
     $image->effects()->colorize($color);
     return $image;
 }
开发者ID:sonjoysam,项目名称:laravel-image,代码行数:13,代码来源:ImageManager.php

示例11: applyColorizeFilter

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

示例12: applyEffect

 /**
  * Применяет эффект к изображению.
  * @param ImageInterface $Image
  * @param string $effect
  * @param string $additional
  * @return bool
  */
 private function applyEffect(ImageInterface $Image, $effect, $additional = null)
 {
     switch ($effect) {
         case 'origin':
             break;
         case 'negative':
             $Image->effects()->negative();
             break;
         case 'grayscale':
             $Image->effects()->grayscale();
             break;
         case 'sharpen':
             $Image->effects()->sharpen();
             break;
         case 'colorize':
             $Image->effects()->colorize($Image->palette()->color($additional));
             break;
         case 'gamma':
             $Image->effects()->gamma($additional);
             break;
         case 'blur':
             $Image->effects()->blur($additional);
             break;
         default:
             return false;
     }
     return true;
 }
开发者ID:andrey-mostovoy,项目名称:photoems,代码行数:35,代码来源:MainLandingPage.php

示例13: toRGB

 /**
  * Ensures that the color mode of the passed image is RGB.
  *
  * @param ImageInterface $image
  *
  * @return ImageInterface $image The modified image
  */
 private function toRGB(ImageInterface $image)
 {
     if ($image->palette()->name() == 'cmyk') {
         $image->usePalette(new RGB());
     }
     return $image;
 }
开发者ID:sulu,项目名称:sulu,代码行数:14,代码来源:ImagineImageConverter.php


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