Skip to content

Phalcon image

NOTE

All classes are prefixed with Phalcon

Image\Adapter\AbstractAdapter Abstract

Source on GitHub

  • Namespace

    • Phalcon\Image\Adapter
  • Uses

    • Phalcon\Image\Enum
    • Phalcon\Image\Exception
  • Extends

  • Implements

    • AdapterInterface

All image adapters must use this class

Properties

/**
 * @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;

Methods

public function background( string $color, int $opacity = int ): AdapterInterface;
Set the background color of an image

public function blur( int $radius ): AdapterInterface;
Blur image

public function crop( int $width, int $height, int $offsetX = null, int $offsetY = null ): AdapterInterface;
Crop an image to the given size

public function flip( int $direction ): AdapterInterface;
Flip the image along the horizontal or vertical axis

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;
Composite one image onto another

public function pixelate( int $amount ): AdapterInterface;
Pixelate image

public function reflection( int $height, int $opacity = int, bool $fadeIn = bool ): AdapterInterface;
Add a reflection to an image

public function render( string $extension = null, int $quality = int ): string;
Render the image and return the binary string

public function resize( int $width = null, int $height = null, int $master = static-constant-access ): AdapterInterface;
Resize the image to the given size

public function rotate( int $degrees ): AdapterInterface;
Rotate the image by a given amount

public function save( string $file = null, int $quality = int ): AdapterInterface;
Save the image

public function sharpen( int $amount ): AdapterInterface;
Sharpen the image by a given amount

public function text( string $text, mixed $offsetX = bool, mixed $offsetY = bool, int $opacity = int, string $color = string, int $size = int, string $fontFile = null ): AdapterInterface;
Add a text to an image with a specified opacity

public function watermark( AdapterInterface $watermark, int $offsetX = int, int $offsetY = int, int $opacity = int ): AdapterInterface;
Add a watermark to an image with the specified opacity

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

Image\Adapter\AdapterInterface Interface

Source on GitHub

  • Namespace

    • Phalcon\Image\Adapter
  • Uses

    • Phalcon\Image\Enum
  • Extends

  • Implements

Interface for Phalcon\Image\Adapter classes

Methods

public function background( string $color, int $opacity = int ): AdapterInterface;
Add a background to an image

public function blur( int $radius ): AdapterInterface;
Blur an image

public function crop( int $width, int $height, int $offsetX = null, int $offsetY = null ): AdapterInterface;
Crop an image

public function flip( int $direction ): AdapterInterface;
Flip an image

public function mask( AdapterInterface $mask ): AdapterInterface;
Add a mask to an image

public function pixelate( int $amount ): AdapterInterface;
Pixelate an image

public function reflection( int $height, int $opacity = int, bool $fadeIn = bool ): AdapterInterface;
Reflect an image

public function render( string $extension = null, int $quality = int ): string;
Render an image

public function resize( int $width = null, int $height = null, int $master = static-constant-access ): AdapterInterface;
Resize an image

public function rotate( int $degrees ): AdapterInterface;
Rotate an image

public function save( string $file = null, int $quality = int ): AdapterInterface;
Save an image

public function sharpen( int $amount ): AdapterInterface;
Sharpen an image

public function text( string $text, int $offsetX = int, int $offsetY = int, int $opacity = int, string $color = string, int $size = int, string $fontFile = null ): AdapterInterface;
Adds text on an image

public function watermark( AdapterInterface $watermark, int $offsetX = int, int $offsetY = int, int $opacity = int ): AdapterInterface;
Add a watermark on an image

Image\Adapter\Gd

Source on GitHub

  • Namespace

    • Phalcon\Image\Adapter
  • Uses

    • Phalcon\Image\Enum
    • Phalcon\Image\Exception
  • Extends

    AbstractAdapter

  • Implements

This file is part of the Phalcon Framework.

(c) Phalcon Team team@phalcon.io

For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.

Methods

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

public function __destruct();
Destructor

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;

Image\Adapter\Imagick

Source on GitHub

  • Namespace

    • Phalcon\Image\Adapter
  • Uses

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

    AbstractAdapter

  • Implements

Phalcon\Image\Adapter\Imagick

Image manipulation support. Resize, rotate, crop etc.

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

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

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

Properties

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

Methods

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

public function __destruct();
Destroys the loaded image to free up resources.

public function liquidRescale( int $width, int $height, int $deltaX = int, int $rigidity = int ): AbstractAdapter;
This method scales the images using liquid rescaling method. Only support Imagick

public function setResourceLimit( int $type, int $limit ): void;
Sets the limit for a particular resource in megabytes

protected function processBackground( int $red, int $green, int $blue, int $opacity ): void;
Execute a background.

protected function processBlur( int $radius ): void;
Blur image

protected function processCrop( int $width, int $height, int $offsetX, int $offsetY ): void;
Execute a crop.

protected function processFlip( int $direction ): void;
Execute a flip.

protected function processMask( AdapterInterface $image ): void;
Composite one image onto another

protected function processPixelate( int $amount ): void;
Pixelate image

protected function processReflection( int $height, int $opacity, bool $fadeIn ): void;
Execute a reflection.

protected function processRender( string $extension, int $quality ): string;
Execute a render.

protected function processResize( int $width, int $height ): void;
Execute a resize.

protected function processRotate( int $degrees ): void;
Execute a rotation.

protected function processSave( string $file, int $quality ): void;
Execute a save.

protected function processSharpen( int $amount ): void;
Execute a sharpen.

protected function processText( string $text, mixed $offsetX, mixed $offsetY, int $opacity, int $red, int $green, int $blue, int $size, string $fontFile = null ): void;
Execute a text

protected function processWatermark( AdapterInterface $image, int $offsetX, int $offsetY, int $opacity ): void;
Add Watermark

Image\Enum

Source on GitHub

  • Namespace

    • Phalcon\Image
  • Uses

  • Extends

  • Implements

This file is part of the Phalcon Framework.

(c) Phalcon Team team@phalcon.io

For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.

Constants

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;

Image\Exception

Source on GitHub

  • Namespace

    • Phalcon\Image
  • Uses

  • Extends

    \Exception

  • Implements

Exceptions thrown in Phalcon\Image will use this class

Image\ImageFactory

Source on GitHub

  • Namespace

    • Phalcon\Image
  • Uses

    • Phalcon\Factory\AbstractFactory
    • Phalcon\Image\Adapter\AdapterInterface
  • Extends

    AbstractFactory

  • Implements

This file is part of the Phalcon Framework.

(c) Phalcon Team team@phalcon.io

For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.

Methods

public function __construct( array $services = [] );
Constructor

public function load( mixed $config ): AdapterInterface;
Factory to create an instance from a Config object

public function newInstance( string $name, string $file, int $width = null, int $height = null ): AdapterInterface;
Creates a new instance

protected function getExceptionClass(): string;

protected function getServices(): array;
Returns the available adapters