本文整理汇总了PHP中Intervention\Image\Image类的典型用法代码示例。如果您正苦于以下问题:PHP Image类的具体用法?PHP Image怎么用?PHP Image使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Image类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Perform orientation image manipulation.
* @param Image $image The source image.
* @return Image The manipulated image.
*/
public function run(Image $image)
{
$orientation = $this->getOrientation();
if ($orientation === 'auto') {
return $image->orientate();
}
return $image->rotate($orientation);
}
开发者ID:kleisauke,项目名称:imagesweserv,代码行数:13,代码来源:Orientation.php
示例2: process
public function process(Image $image)
{
if ($this->request->query->has('progressive') || $this->request->query->has('interlace')) {
$process = $this->request->query->has('progressive') ? $this->request->query->get('progressive') : $this->request->query->get('interlace');
$image->interlace((bool) $process);
}
}
开发者ID:ambroisemaupate,项目名称:intervention-request,代码行数:7,代码来源:ProgressiveProcessor.php
示例3: applyFilter
public function applyFilter(Image $image)
{
return $image->resize(150, 100, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
})->encode('jpg', 75);
}
开发者ID:stjanilofts,项目名称:normx,代码行数:7,代码来源:logoFilter.php
示例4: run
/**
* @param \Intervention\Image\Image $image
*
* @return void
*/
public function run(Image $image)
{
$callback = function (Constraint $constraint) {
$constraint->upsize();
};
$image->fit($this->width, $this->height, $callback, $this->position)->interlace($this->interlace);
}
开发者ID:livetyping,项目名称:hermitage,代码行数:12,代码来源:Fit.php
示例5: applyFilter
public function applyFilter(Image $image)
{
return $image->greyscale()->resize(150, 100, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
});
}
开发者ID:stjanilofts,项目名称:ofncms,代码行数:7,代码来源:logoFilter.php
示例6: checkHeight
/**
* Check height first in resizing
*
* @param \Intervention\Image\Image $image
* @param integer $height
*
* @return integer
*/
private function checkHeight($image, $height)
{
if ($image->height() < $height) {
return $image->height();
}
return $height;
}
开发者ID:jayaregalinada,项目名称:portfolio-legacy,代码行数:15,代码来源:ImageProcessor.php
示例7: applyFilter
/**
* Applies filter effects to the given image
*
* @param Image\Image $image The image to filter.
*
* @return Image\Image The filtered image.
*/
public function applyFilter(Image\Image $image)
{
$image->fit(100, 100, function ($constraint) {
$constraint->upsize();
});
return $image;
}
开发者ID:BitmanNL,项目名称:traffictower-cms,代码行数:14,代码来源:ThumbnailFilter.php
示例8: 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
示例9: applyFilter
public function applyFilter(Image $image)
{
return $image->fit(1400, 700, function ($constraint) {
//$constraint->aspectRatio();
//$constraint->upsize();
})->encode('jpg', 70);
}
开发者ID:stjanilofts,项目名称:normx,代码行数:7,代码来源:slickFilter.php
示例10: 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
示例11: applyFilter
public function applyFilter(Image $image)
{
return $image->resize(420, 420, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
});
}
开发者ID:stjanilofts,项目名称:ofncms,代码行数:7,代码来源:productlistFilter.php
示例12: 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
示例13: 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
示例14: execute
/**
* Applies an alpha mask to an image
*
* @param \Intervention\Image\Image $image
* @return boolean
*/
public function execute($image)
{
$mask_source = $this->argument(0)->value();
$mask_w_alpha = $this->argument(1)->type('bool')->value(false);
// get imagick
$imagick = $image->getCore();
// build mask image from source
$mask = $image->getDriver()->init($mask_source);
// resize mask to size of current image (if necessary)
$image_size = $image->getSize();
if ($mask->getSize() != $image_size) {
$mask->resize($image_size->width, $image_size->height);
}
$imagick->setImageMatte(true);
if ($mask_w_alpha) {
// just mask with alpha map
$imagick->compositeImage($mask->getCore(), \Imagick::COMPOSITE_DSTIN, 0, 0);
} else {
// get alpha channel of original as greyscale image
$original_alpha = clone $imagick;
$original_alpha->separateImageChannel(\Imagick::CHANNEL_ALPHA);
// use red channel from mask ask alpha
$mask_alpha = clone $mask->getCore();
$mask_alpha->compositeImage($mask->getCore(), \Imagick::COMPOSITE_DEFAULT, 0, 0);
// $mask_alpha->setImageAlphaChannel(\Imagick::ALPHACHANNEL_DEACTIVATE);
$mask_alpha->separateImageChannel(\Imagick::CHANNEL_ALL);
// combine both alphas from original and mask
$original_alpha->compositeImage($mask_alpha, \Imagick::COMPOSITE_COPYOPACITY, 0, 0);
// mask the image with the alpha combination
$imagick->compositeImage($original_alpha, \Imagick::COMPOSITE_DSTIN, 0, 0);
}
return true;
}
开发者ID:hilmysyarif,项目名称:sic,代码行数:39,代码来源:MaskCommand.php
示例15: execute
/**
* Builds PSR7 stream based on image data. Method uses Guzzle PSR7
* implementation as easiest choice.
*
* @param \Intervention\Image\Image $image
* @return boolean
*/
public function execute($image)
{
$format = $this->argument(0)->value();
$quality = $this->argument(1)->between(0, 100)->value();
$this->setOutput(\GuzzleHttp\Psr7\stream_for($image->encode($format, $quality)->getEncoded()));
return true;
}
开发者ID:hilmysyarif,项目名称:sic,代码行数:14,代码来源:StreamCommand.php
示例16: process
public function process(Image $image)
{
if ($this->request->query->has('fit') && !$this->request->query->has('width') && !$this->request->query->has('height') && 1 === preg_match('#^([0-9]+)[x\\:]([0-9]+)$#', $this->request->query->get('fit'), $fit)) {
$image->fit($fit[1], $fit[2], function (Constraint $constraint) {
$constraint->upsize();
});
}
}
开发者ID:ambroisemaupate,项目名称:intervention-request,代码行数:8,代码来源:FitProcessor.php
示例17: run
/**
* Perform brightness image manipulation.
* @param Request $request The request object.
* @param Image $image The source image.
* @return Image The manipulated image.
*/
public function run(Request $request, Image $image)
{
$brightness = $this->getBrightness($request->get('bri'));
if ($brightness) {
$image->brightness($brightness);
}
return $image;
}
开发者ID:awebc,项目名称:web_xbf,代码行数:14,代码来源:Brightness.php
示例18: execute
/**
* Applies blur effect on image
*
* @param \Intervention\Image\Image $image
* @return boolean
*/
public function execute($image)
{
$amount = $this->argument(0)->between(0, 100)->value(1);
for ($i = 0; $i < intval($amount); $i++) {
imagefilter($image->getCore(), IMG_FILTER_GAUSSIAN_BLUR);
}
return true;
}
开发者ID:hilmysyarif,项目名称:sic,代码行数:14,代码来源:BlurCommand.php
示例19: run
/**
* Perform blur image manipulation.
* @param Image $image The source image.
* @return Image The manipulated image.
*/
public function run(Image $image)
{
$blur = $this->getBlur();
if ($blur !== null) {
$image->blur($blur);
}
return $image;
}
开发者ID:whismat,项目名称:glide,代码行数:13,代码来源:Blur.php
示例20: run
/**
* Perform contrast image manipulation.
* @param Request $request The request object.
* @param Image $image The source image.
* @return Image The manipulated image.
*/
public function run(Request $request, Image $image)
{
$contrast = $this->getContrast($request->get('con'));
if ($contrast) {
$image->contrast($contrast);
}
return $image;
}
开发者ID:awebc,项目名称:web_xbf,代码行数:14,代码来源:Contrast.php
注:本文中的Intervention\Image\Image类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论