跳转到内容

Phalcon图像

注意

所有类都以前缀命名Phalcon

图像\适配器\AbstractAdapterAbstract

GitHub上的源码

  • 命名空间

    • Phalcon\Image\Adapter
  • 使用

    • Phalcon\Image\Enum
    • Phalcon\Image\Exception
  • 继承

  • 实现

    • AdapterInterface

所有图像适配器必须使用此类

属性

/**
 * @var string
 */
protected $file;

/**
 * Image height
 *
 * @var int
 */
protected $height;

/**
 * @var mixed|null
 */
protected $image;

/**
 * Image mime type
 *
 * @var string
 */
protected $mime;

/**
 * @var string
 */
protected $realpath;

/**
 * Image type
 *
 * Driver dependent
 *
 * @var int
 */
protected $type;

/**
 * Image width
 *
 * @var int
 */
protected $width;

方法

public function background( string $color, int $opacity = int ): AdapterInterface;
设置图像的背景颜色

public function blur( int $radius ): AdapterInterface;
模糊图像

public function crop( int $width, int $height, int $offsetX = null, int $offsetY = null ): AdapterInterface;
将图像裁剪为给定大小

public function flip( int $direction ): AdapterInterface;
沿水平或垂直轴翻转图像

public function getHeight(): int;
public function getImage();
public function getMime(): string;
public function getRealpath(): string;
public function getType(): int;
public function getWidth(): int;

public function mask( AdapterInterface $mask ): AdapterInterface;
将一幅图像合成到另一幅图像上

public function pixelate( int $amount ): AdapterInterface;
像素化图像

public function reflection( int $height, int $opacity = int, bool $fadeIn = bool ): AdapterInterface;
向图像添加反射效果

public function render( string $extension = null, int $quality = int ): string;
渲染图像并返回二进制字符串

public function resize( int $width = null, int $height = null, int $master = static-constant-access ): AdapterInterface;
将图像调整为给定大小

public function rotate( int $degrees ): AdapterInterface;
以给定量旋转图像

public function save( string $file = null, int $quality = int ): AdapterInterface;
保存图像

public function sharpen( int $amount ): AdapterInterface;
以给定量锐化图像

public function text( string $text, mixed $offsetX = bool, mixed $offsetY = bool, int $opacity = int, string $color = string, int $size = int, string $fontFile = null ): AdapterInterface;
在图像上添加指定不透明度的文字

public function watermark( AdapterInterface $watermark, int $offsetX = int, int $offsetY = int, int $opacity = int ): AdapterInterface;
使用指定不透明度向图像添加水印

protected function checkHighLow( int $value, int $min = int, int $max = int ): int;

图像\适配器\适配器接口Interface

GitHub上的源码

  • 命名空间

    • Phalcon\Image\Adapter
  • 使用

    • Phalcon\Image\Enum
  • 继承

  • 实现

Phalcon\Image\Adapter类的接口

方法

public function background( string $color, int $opacity = int ): AdapterInterface;
向图像添加背景

public function blur( int $radius ): AdapterInterface;
模糊图像

public function crop( int $width, int $height, int $offsetX = null, int $offsetY = null ): AdapterInterface;
裁剪图像

public function flip( int $direction ): AdapterInterface;
翻转图像

public function mask( AdapterInterface $mask ): AdapterInterface;
向图像添加遮罩

public function pixelate( int $amount ): AdapterInterface;
像素化图像

public function reflection( int $height, int $opacity = int, bool $fadeIn = bool ): AdapterInterface;
反射图像

public function render( string $extension = null, int $quality = int ): string;
渲染图像

public function resize( int $width = null, int $height = null, int $master = static-constant-access ): AdapterInterface;
缩放图像

public function rotate( int $degrees ): AdapterInterface;
旋转图像

public function save( string $file = null, int $quality = int ): AdapterInterface;
保存图像

public function sharpen( int $amount ): AdapterInterface;
锐化图像

public function text( string $text, int $offsetX = int, int $offsetY = int, int $opacity = int, string $color = string, int $size = int, string $fontFile = null ): AdapterInterface;
在图像上添加文字

public function watermark( AdapterInterface $watermark, int $offsetX = int, int $offsetY = int, int $opacity = int ): AdapterInterface;
在图像上添加水印

图像\适配器\Gd

GitHub上的源码

  • 命名空间

    • Phalcon\Image\Adapter
  • 使用

    • Phalcon\Image\Enum
    • Phalcon\Image\Exception
  • 继承

    AbstractAdapter

  • 实现

该文件是Phalcon框架的一部分。

(c) Phalcon团队team@phalcon.io

有关完整的版权和许可信息,请查看随此源代码分发的LICENSE.txt文件。

方法

public function __construct( string $file, int $width = null, int $height = null );

public function __destruct();
析构函数

public function getVersion(): string;
protected function processBackground( int $red, int $green, int $blue, int $opacity ): void;
protected function processBlur( int $radius ): void;
protected function processCreate( int $width, int $height );
protected function processCrop( int $width, int $height, int $offsetX, int $offsetY ): void;
protected function processFlip( int $direction ): void;
protected function processMask( AdapterInterface $mask );
protected function processPixelate( int $amount ): void;
protected function processReflection( int $height, int $opacity, bool $fadeIn ): void;
protected function processRender( string $extension, int $quality );
protected function processResize( int $width, int $height ): void;
protected function processRotate( int $degrees ): void;
protected function processSave( string $file, int $quality ): bool;
protected function processSharpen( int $amount ): void;
protected function processText( string $text, mixed $offsetX, mixed $offsetY, int $opacity, int $red, int $green, int $blue, int $size, string $fontFile = null ): void;
protected function processWatermark( AdapterInterface $watermark, int $offsetX, int $offsetY, int $opacity ): void;

图像\适配器\Imagick

GitHub上的源码

  • 命名空间

    • Phalcon\Image\Adapter
  • 使用

    • Imagick
    • ImagickDraw
    • ImagickDrawException
    • ImagickException
    • ImagickPixel
    • ImagickPixelException
    • Phalcon\Image\Enum
    • Phalcon\Image\Exception
  • 继承

    AbstractAdapter

  • 实现

Phalcon\Image\Adapter\Imagick

图像操作支持。调整大小,旋转,裁剪等。

$image = new \Phalcon\Image\Adapter\Imagick("upload/test.jpg");

$image->resize(200, 200)->rotate(90)->crop(100, 100);

if ($image->save()) {
    echo "success";
}

属性

/**
 * @var int
 */
protected $version = ;

方法

public function __construct( string $file, int $width = null, int $height = null );
构造函数

public function __destruct();
销毁加载的图像以释放资源。

public function liquidRescale( int $width, int $height, int $deltaX = int, int $rigidity = int ): AbstractAdapter;
此方法使用液态缩放法来缩放图像。仅支持Imagick

public function setResourceLimit( int $type, int $limit ): void;
以兆字节为单位设置特定资源的限制

protected function processBackground( int $red, int $green, int $blue, int $opacity ): void;
执行背景操作。

protected function processBlur( int $radius ): void;
模糊图像

protected function processCrop( int $width, int $height, int $offsetX, int $offsetY ): void;
执行裁剪。

protected function processFlip( int $direction ): void;
执行翻转。

protected function processMask( AdapterInterface $image ): void;
将一幅图像合成到另一幅图像上

protected function processPixelate( int $amount ): void;
像素化图像

protected function processReflection( int $height, int $opacity, bool $fadeIn ): void;
执行反射。

protected function processRender( string $extension, int $quality ): string;
执行渲染。

protected function processResize( int $width, int $height ): void;
执行缩放。

protected function processRotate( int $degrees ): void;
执行旋转。

protected function processSave( string $file, int $quality ): void;
执行保存。

protected function processSharpen( int $amount ): void;
执行锐化。

protected function processText( string $text, mixed $offsetX, mixed $offsetY, int $opacity, int $red, int $green, int $blue, int $size, string $fontFile = null ): void;
执行文本操作

protected function processWatermark( AdapterInterface $image, int $offsetX, int $offsetY, int $opacity ): void;
添加水印

图像\Enum

GitHub上的源码

  • 命名空间

    • Phalcon\Image
  • 使用

  • 继承

  • 实现

该文件是Phalcon框架的一部分。

(c) Phalcon团队team@phalcon.io

有关完整的版权和许可信息,请查看随此源代码分发的LICENSE.txt文件。

常量

const AUTO = 4;
const HEIGHT = 3;
const HORIZONTAL = 11;
const INVERSE = 5;
const NONE = 1;
const PRECISE = 6;
const TENSILE = 7;
const VERTICAL = 12;
const WIDTH = 2;

图像\Exception

GitHub上的源码

  • 命名空间

    • Phalcon\Image
  • 使用

  • 继承

    \Exception

  • 实现

在Phalcon\Image中抛出的异常将使用此类

图像\ImageFactory

GitHub上的源码

  • 命名空间

    • Phalcon\Image
  • 使用

    • Phalcon\Factory\AbstractFactory
    • Phalcon\Image\Adapter\AdapterInterface
  • 继承

    AbstractFactory

  • 实现

该文件是Phalcon框架的一部分。

(c) Phalcon团队team@phalcon.io

有关完整的版权和许可信息,请查看随此源代码分发的LICENSE.txt文件。

方法

public function __construct( array $services = [] );
构造函数

public function load( mixed $config ): AdapterInterface;
从Config对象创建实例的工厂

public function newInstance( string $name, string $file, int $width = null, int $height = null ): AdapterInterface;
创建一个新实例

protected function getExceptionClass(): string;

protected function getServices(): array;
返回可用的适配器

无噪 Logo
无噪文档
25 年 6 月翻译
文档源↗