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


PHP Image::getCore方法代码示例

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


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

示例1: execute

 /**
  * Reduces colors of a given image
  *
  * @param  \Intervention\Image\Image $image
  * @return boolean
  */
 public function execute($image)
 {
     $count = $this->argument(0)->value();
     $matte = $this->argument(1)->value();
     // get current image size
     $size = $image->getSize();
     // build 2 color alpha mask from original alpha
     $alpha = clone $image->getCore();
     $alpha->separateImageChannel(\Imagick::CHANNEL_ALPHA);
     $alpha->transparentPaintImage('#ffffff', 0, 0, false);
     $alpha->separateImageChannel(\Imagick::CHANNEL_ALPHA);
     $alpha->negateImage(false);
     if ($matte) {
         // get matte color
         $mattecolor = $image->getDriver()->parseColor($matte)->getPixel();
         // create matte image
         $canvas = new \Imagick();
         $canvas->newImage($size->width, $size->height, $mattecolor, 'png');
         // lower colors of original and copy to matte
         $image->getCore()->quantizeImage($count, \Imagick::COLORSPACE_RGB, 0, false, false);
         $canvas->compositeImage($image->getCore(), \Imagick::COMPOSITE_DEFAULT, 0, 0);
         // copy new alpha to canvas
         $canvas->compositeImage($alpha, \Imagick::COMPOSITE_COPYOPACITY, 0, 0);
         // replace core
         $image->setCore($canvas);
     } else {
         $image->getCore()->quantizeImage($count, \Imagick::COLORSPACE_RGB, 0, false, false);
         $image->getCore()->compositeImage($alpha, \Imagick::COMPOSITE_COPYOPACITY, 0, 0);
     }
     return true;
 }
开发者ID:hilmysyarif,项目名称:sic,代码行数:37,代码来源:LimitColorsCommand.php

示例2: execute

 /**
  * Applies a pixelation effect to a given image
  *
  * @param  \Intervention\Image\Image $image
  * @return boolean
  */
 public function execute($image)
 {
     $size = $this->argument(0)->type('digit')->value(10);
     $width = $image->getWidth();
     $height = $image->getHeight();
     $image->getCore()->scaleImage(max(1, $width / $size), max(1, $height / $size));
     $image->getCore()->scaleImage($width, $height);
     return true;
 }
开发者ID:hilmysyarif,项目名称:sic,代码行数:15,代码来源:PixelateCommand.php

示例3: applyToImage

 /**
  * Draw ellipse instance on given image
  *
  * @param  Image   $image
  * @param  integer $x
  * @param  integer $y
  * @return boolean
  */
 public function applyToImage(Image $image, $x = 0, $y = 0)
 {
     $background = new Color($this->background);
     imagefilledellipse($image->getCore(), $x, $y, $this->width, $this->height, $background->getInt());
     if ($this->hasBorder()) {
         $border_color = new Color($this->border_color);
         imagesetthickness($image->getCore(), $this->border_width);
         imageellipse($image->getCore(), $x, $y, $this->width, $this->height, $border_color->getInt());
     }
     return true;
 }
开发者ID:RHoKAustralia,项目名称:onaroll21_backend,代码行数:19,代码来源:EllipseShape.php

示例4: applyToImage

 /**
  * Draw polygon on given image
  *
  * @param  Image   $image
  * @param  integer $x
  * @param  integer $y
  * @return boolean
  */
 public function applyToImage(Image $image, $x = 0, $y = 0)
 {
     $background = new Color($this->background);
     imagefilledpolygon($image->getCore(), $this->points, intval(count($this->points) / 2), $background->getInt());
     if ($this->hasBorder()) {
         $border_color = new Color($this->border_color);
         imagesetthickness($image->getCore(), $this->border_width);
         imagepolygon($image->getCore(), $this->points, intval(count($this->points) / 2), $border_color->getInt());
     }
     return true;
 }
开发者ID:hilmysyarif,项目名称:sic,代码行数:19,代码来源:PolygonShape.php

示例5: execute

 /**
  * Mirrors an image
  *
  * @param  \Intervention\Image\Image $image
  * @return boolean
  */
 public function execute($image)
 {
     $mode = $this->argument(0)->value('h');
     if (in_array(strtolower($mode), array(2, 'v', 'vert', 'vertical'))) {
         // flip vertical
         return $image->getCore()->flipImage();
     } else {
         // flip horizontal
         return $image->getCore()->flopImage();
     }
 }
开发者ID:hilmysyarif,项目名称:sic,代码行数:17,代码来源:FlipCommand.php

示例6: applyToImage

 /**
  * Draw rectangle to given image at certain position
  *
  * @param  Image   $image
  * @param  integer $x
  * @param  integer $y
  * @return boolean
  */
 public function applyToImage(Image $image, $x = 0, $y = 0)
 {
     $background = new Color($this->background);
     imagefilledrectangle($image->getCore(), $this->x1, $this->y1, $this->x2, $this->y2, $background->getInt());
     if ($this->hasBorder()) {
         $border_color = new Color($this->border_color);
         imagesetthickness($image->getCore(), $this->border_width);
         imagerectangle($image->getCore(), $this->x1, $this->y1, $this->x2, $this->y2, $border_color->getInt());
     }
     return true;
 }
开发者ID:manhvu1212,项目名称:videoplatform,代码行数:19,代码来源:RectangleShape.php

示例7: execute

 /**
  * Removes all frames of an animation except one
  *
  * @param  \Intervention\Image\Image $image
  * @return boolean
  */
 public function execute($image)
 {
     $keepIndex = $this->argument(0)->type('int')->value(0);
     foreach ($image as $key => $frame) {
         if ($keepIndex == $key) {
             break;
         }
     }
     $frame = $image->getDriver()->init($image->getCore()->getImageBlob());
     // remove old core
     $image->getCore()->clear();
     // set new core
     $image->setContainer($frame->getContainer());
     return true;
 }
开发者ID:EdgarPost,项目名称:image,代码行数:21,代码来源:StopAnimationCommand.php

示例8: execute

 /**
  * Reduces colors of a given image
  *
  * @param  \Intervention\Image\Image $image
  * @return boolean
  */
 public function execute($image)
 {
     $count = $this->argument(0)->value();
     $matte = $this->argument(1)->value();
     // get current image size
     $size = $image->getSize();
     // create empty canvas
     $resource = imagecreatetruecolor($size->width, $size->height);
     // define matte
     if (is_null($matte)) {
         $matte = imagecolorallocatealpha($resource, 255, 255, 255, 127);
     } else {
         $matte = $image->getDriver()->parseColor($matte)->getInt();
     }
     // fill with matte and copy original image
     imagefill($resource, 0, 0, $matte);
     // set transparency
     imagecolortransparent($resource, $matte);
     // copy original image
     imagecopy($resource, $image->getCore(), 0, 0, 0, 0, $size->width, $size->height);
     if (is_numeric($count) && $count <= 256) {
         // decrease colors
         imagetruecolortopalette($resource, true, $count);
     }
     // set new resource
     $image->setCore($resource);
     return true;
 }
开发者ID:shubhomoy,项目名称:evolve,代码行数:34,代码来源:LimitColorsCommand.php

示例9: execute

 /**
  * Reads size of given image instance in pixels
  *
  * @param  \Intervention\Image\Image $image
  * @return boolean
  */
 public function execute($image)
 {
     /** @var \Imagick $core */
     $core = $image->getCore();
     $this->setOutput(new Size($core->getImageWidth(), $core->getImageHeight()));
     return true;
 }
开发者ID:alvarobfdev,项目名称:applog,代码行数:13,代码来源:GetSizeCommand.php

示例10: execute

 /**
  * Read color information from a certain position
  *
  * @param  \Intervention\Image\Image $image
  * @return boolean
  */
 public function execute($image)
 {
     $x = $this->argument(0)->type('digit')->required()->value();
     $y = $this->argument(1)->type('digit')->required()->value();
     $format = $this->argument(2)->type('string')->value('array');
     // pick color
     $color = imagecolorat($image->getCore(), $x, $y);
     if (!imageistruecolor($image->getCore())) {
         $color = imagecolorsforindex($image->getCore(), $color);
         $color['alpha'] = round(1 - $color['alpha'] / 127, 2);
     }
     $color = new Color($color);
     // format to output
     $this->setOutput($color->format($format));
     return true;
 }
开发者ID:Roc4rdho,项目名称:app,代码行数:22,代码来源:PickColorCommand.php

示例11: execute

 /**
  * Changes balance of different RGB color channels
  *
  * @param  \Intervention\Image\Image $image
  * @return boolean
  */
 public function execute($image)
 {
     $red = $this->argument(0)->between(-100, 100)->required()->value();
     $green = $this->argument(1)->between(-100, 100)->required()->value();
     $blue = $this->argument(2)->between(-100, 100)->required()->value();
     // normalize colorize levels
     $red = $this->normalizeLevel($red);
     $green = $this->normalizeLevel($green);
     $blue = $this->normalizeLevel($blue);
     $qrange = $image->getCore()->getQuantumRange();
     // apply
     $image->getCore()->levelImage(0, $red, $qrange['quantumRangeLong'], \Imagick::CHANNEL_RED);
     $image->getCore()->levelImage(0, $green, $qrange['quantumRangeLong'], \Imagick::CHANNEL_GREEN);
     $image->getCore()->levelImage(0, $blue, $qrange['quantumRangeLong'], \Imagick::CHANNEL_BLUE);
     return true;
 }
开发者ID:hilmysyarif,项目名称:sic,代码行数:22,代码来源:ColorizeCommand.php

示例12: execute

 /**
  * Insert another image into given image
  *
  * @param  \Intervention\Image\Image $image
  * @return boolean
  */
 public function execute($image)
 {
     $source = $this->argument(0)->required()->value();
     $position = $this->argument(1)->type('string')->value();
     $x = $this->argument(2)->type('digit')->value(0);
     $y = $this->argument(3)->type('digit')->value(0);
     // build watermark
     $watermark = $image->getDriver()->init($source);
     // define insertion point
     $image_size = $image->getSize()->align($position, $x, $y);
     $watermark_size = $watermark->getSize()->align($position);
     $target = $image_size->relativePosition($watermark_size);
     // insert image at position
     imagealphablending($image->getCore(), true);
     return imagecopy($image->getCore(), $watermark->getCore(), $target->x, $target->y, 0, 0, $watermark_size->width, $watermark_size->height);
 }
开发者ID:hilmysyarif,项目名称:sic,代码行数:22,代码来源:InsertCommand.php

示例13: applyFilter

 /**
  * Applies filter effects to the given image
  *
  * @param Image\Image $image The image to filter.
  *
  * @return Image\Image The filtered image.
  *
  * @throws FilterException if the image filter algorithm fails.
  */
 public function applyFilter(Image\Image $image)
 {
     if ($this->level <= 0) {
         $gd = $image->getCore();
         $width = imagesx($gd);
         $height = imagesy($gd);
         for ($x = 0; $x < $width; ++$x) {
             for ($y = 0; $y < $height; ++$y) {
                 $rgba = imagecolorsforindex($gd, imagecolorat($gd, $x, $y));
                 $r = $rgba['red'];
                 $g = $rgba['green'];
                 $b = $rgba['blue'];
                 $a = $rgba['alpha'];
                 $level = $this->level * -1;
                 $max = max($r, $g, $b);
                 $avg = ($r + $g + $b) / 3;
                 $amt = abs($max - $avg) * 2 / 255 * $level / 100;
                 if ($r !== $max) {
                     $r += ($max - $r) * $amt;
                 }
                 if ($g !== $max) {
                     $g += ($max - $g) * $amt;
                 }
                 if ($b !== $max) {
                     $b += ($max - $b) * $amt;
                 }
                 imagesetpixel($gd, $x, $y, imagecolorallocatealpha($gd, $r, $g, $b, $a));
             }
         }
         $image->setCore($gd);
     } else {
         $image->filter(new SaturateFilter($this->level));
     }
     return $image;
 }
开发者ID:BitmanNL,项目名称:traffictower-cms,代码行数:44,代码来源:VibranceFilter.php

示例14: applyToImage

 /**
  * Draw ellipse instance on given image
  *
  * @param  Image   $image
  * @param  integer $x
  * @param  integer $y
  * @return boolean
  */
 public function applyToImage(Image $image, $x = 0, $y = 0)
 {
     // parse background color
     $background = new Color($this->background);
     if ($this->hasBorder()) {
         // slightly smaller ellipse to keep 1px bordered edges clean
         imagefilledellipse($image->getCore(), $x, $y, $this->width - 1, $this->height - 1, $background->getInt());
         $border_color = new Color($this->border_color);
         imagesetthickness($image->getCore(), $this->border_width);
         // gd's imageellipse doesn't respect imagesetthickness so i use imagearc with 359.9 degrees here
         imagearc($image->getCore(), $x, $y, $this->width, $this->height, 0, 359.99, $border_color->getInt());
     } else {
         imagefilledellipse($image->getCore(), $x, $y, $this->width, $this->height, $background->getInt());
     }
     return true;
 }
开发者ID:shomimn,项目名称:builder,代码行数:24,代码来源:EllipseShape.php

示例15: execute

 /**
  * Saves a backups of current state of image core
  *
  * @param  \Intervention\Image\Image $image
  * @return boolean
  */
 public function execute($image)
 {
     $backupName = $this->argument(0)->value();
     // clone current image resource
     $image->setBackup(clone $image->getCore(), $backupName);
     return true;
 }
开发者ID:hilmysyarif,项目名称:sic,代码行数:13,代码来源:BackupCommand.php


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