當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。