Phalcon image
NOTE
All classes are prefixed with Phalcon
Image\Adapter\AbstractAdapter¶
Abstract Source on GitHub
All image adapters must use this class
Phalcon\Image\Adapter\AbstractAdapter— implementsPhalcon\Image\Adapter\AdapterInterface
Uses Phalcon\Image\Enum · Phalcon\Image\Exception · Phalcon\Image\Exceptions\MissingDimensions · Phalcon\Image\Exceptions\MissingHeight · Phalcon\Image\Exceptions\MissingWidth
Method Summary¶
public AdapterInterface background(string $color,int $opacity = 100) Set the background color of an image public AdapterInterface blur( int $radius ) Blur image public AdapterInterface crop(int $width,int $height,mixed $offsetX = null,mixed $offsetY = null) Crop an image to the given size public AdapterInterface flip( int $direction ) Flip the image along the horizontal or vertical axis public int getHeight() public getImage() public string getMime() public string getRealpath() public int getType() public int getWidth() public AdapterInterface mask( AdapterInterface $mask ) Composite one image onto another public AdapterInterface pixelate( int $amount ) Pixelate image public AdapterInterface reflection(int $height,int $opacity = 100,bool $fadeIn = false) Add a reflection to an image public string render(string $extension = null,int $quality = 100) Render the image and return the binary string public AdapterInterface resize(int $width = null,int $height = null,int $master = Enum::AUTO) Resize the image to the given size public AdapterInterface rotate( int $degrees ) Rotate the image by a given amount public AdapterInterface save(string $file = null,int $quality = -1) Save the image public AdapterInterface sharpen( int $amount ) Sharpen the image by a given amount public AdapterInterface text(string $text,mixed $offsetX = false,mixed $offsetY = false,int $opacity = 100,string $color = "000000",int $size = 12,string $fontFile = null) Add a text to an image with a specified opacity public AdapterInterface watermark(AdapterInterface $watermark,int $offsetX = 0,int $offsetY = 0,int $opacity = 100) Add a watermark to an image with the specified opacity protected int checkHighLow(int $value,int $min = 0,int $max = 100) Properties¶
protected string $file protected int $height Image height protected mixed|null $image = null protected string $mime Image mime type protected string $realpath protected int $type Image type Driver dependent protected int $width Image width Methods¶
background()¶
Set the background color of an image
blur()¶
Blur image
crop()¶
public function crop(
int $width,
int $height,
mixed $offsetX = null,
mixed $offsetY = null
): AdapterInterface;
Crop an image to the given size
flip()¶
Flip the image along the horizontal or vertical axis
getHeight()¶
getImage()¶
getMime()¶
getRealpath()¶
getType()¶
getWidth()¶
mask()¶
Composite one image onto another
pixelate()¶
Pixelate image
reflection()¶
public function reflection(
int $height,
int $opacity = 100,
bool $fadeIn = false
): AdapterInterface;
Add a reflection to an image
render()¶
Render the image and return the binary string
resize()¶
public function resize(
int $width = null,
int $height = null,
int $master = Enum::AUTO
): AdapterInterface;
Resize the image to the given size
rotate()¶
Rotate the image by a given amount
save()¶
Save the image
sharpen()¶
Sharpen the image by a given amount
text()¶
public function text(
string $text,
mixed $offsetX = false,
mixed $offsetY = false,
int $opacity = 100,
string $color = "000000",
int $size = 12,
string $fontFile = null
): AdapterInterface;
Add a text to an image with a specified opacity
watermark()¶
public function watermark(
AdapterInterface $watermark,
int $offsetX = 0,
int $offsetY = 0,
int $opacity = 100
): AdapterInterface;
Add a watermark to an image with the specified opacity
checkHighLow()¶
Image\Adapter\AdapterInterface¶
Interface Source on GitHub
Interface for Phalcon\Image\Adapter classes
Phalcon\Image\Adapter\AdapterInterface
Uses Phalcon\Image\Enum
Method Summary¶
public AdapterInterface background(string $color,int $opacity = 100) Add a background to an image public AdapterInterface blur( int $radius ) Blur an image public AdapterInterface crop(int $width,int $height,int $offsetX = null,int $offsetY = null) Crop an image public AdapterInterface flip( int $direction ) Flip an image public int getHeight() public int getWidth() public AdapterInterface mask( AdapterInterface $mask ) Add a mask to an image public AdapterInterface pixelate( int $amount ) Pixelate an image public AdapterInterface reflection(int $height,int $opacity = 100,bool $fadeIn = false) Reflect an image public string render(string $extension = null,int $quality = 100) Render an image public AdapterInterface resize(int $width = null,int $height = null,int $master = Enum::AUTO) Resize an image public AdapterInterface rotate( int $degrees ) Rotate an image public AdapterInterface save(string $file = null,int $quality = 100) Save an image public AdapterInterface sharpen( int $amount ) Sharpen an image public AdapterInterface text(string $text,int $offsetX = 0,int $offsetY = 0,int $opacity = 100,string $color = "000000",int $size = 12,string $fontFile = null) Adds text on an image public AdapterInterface watermark(AdapterInterface $watermark,int $offsetX = 0,int $offsetY = 0,int $opacity = 100) Add a watermark on an image Methods¶
background()¶
Add a background to an image
blur()¶
Blur an image
crop()¶
public function crop(
int $width,
int $height,
int $offsetX = null,
int $offsetY = null
): AdapterInterface;
Crop an image
flip()¶
Flip an image
getHeight()¶
getWidth()¶
mask()¶
Add a mask to an image
pixelate()¶
Pixelate an image
reflection()¶
public function reflection(
int $height,
int $opacity = 100,
bool $fadeIn = false
): AdapterInterface;
Reflect an image
render()¶
Render an image
resize()¶
public function resize(
int $width = null,
int $height = null,
int $master = Enum::AUTO
): AdapterInterface;
Resize an image
rotate()¶
Rotate an image
save()¶
Save an image
sharpen()¶
Sharpen an image
text()¶
public function text(
string $text,
int $offsetX = 0,
int $offsetY = 0,
int $opacity = 100,
string $color = "000000",
int $size = 12,
string $fontFile = null
): AdapterInterface;
Adds text on an image
watermark()¶
public function watermark(
AdapterInterface $watermark,
int $offsetX = 0,
int $offsetY = 0,
int $opacity = 100
): AdapterInterface;
Add a watermark on an image
Image\Adapter\Gd¶
Class Source on GitHub
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.
Phalcon\Image\Adapter\AbstractAdapterPhalcon\Image\Adapter\Gd
Uses Phalcon\Image\Enum · Phalcon\Image\Exception · Phalcon\Image\Exceptions\ExtensionNotLoaded · Phalcon\Image\Exceptions\ImageLoadFailed · Phalcon\Image\Exceptions\TextRenderingFailed · Phalcon\Image\Exceptions\UnsupportedImageType · Phalcon\Image\Exceptions\VersionMismatch
Method Summary¶
public __construct(string $file,int $width = null,int $height = null) public __destruct() Destructor public string getVersion() protected void processBackground(int $red,int $green,int $blue,int $opacity) protected void processBlur( int $radius ) protected processCreate(int $width,int $height) protected void processCrop(int $width,int $height,int $offsetX,int $offsetY) protected void processFlip( int $direction ) protected processMask( AdapterInterface $mask ) protected void processPixelate( int $amount ) protected void processReflection(int $height,int $opacity,bool $fadeIn) protected processRender(string $extension,int $quality) protected void processResize(int $width,int $height) protected void processRotate( int $degrees ) protected bool processSave(string $file,int $quality) protected void processSharpen( int $amount ) protected void processText(string $text,mixed $offsetX,mixed $offsetY,int $opacity,int $red,int $green,int $blue,int $size,string $fontFile = null) protected void processWatermark(AdapterInterface $watermark,int $offsetX,int $offsetY,int $opacity) Methods¶
__construct()¶
__destruct()¶
Destructor
getVersion()¶
processBackground()¶
processBlur()¶
processCreate()¶
processCrop()¶
processFlip()¶
processMask()¶
processPixelate()¶
processReflection()¶
processRender()¶
processResize()¶
processRotate()¶
processSave()¶
processSharpen()¶
processText()¶
protected function processText(
string $text,
mixed $offsetX,
mixed $offsetY,
int $opacity,
int $red,
int $green,
int $blue,
int $size,
string $fontFile = null
): void;
processWatermark()¶
protected function processWatermark(
AdapterInterface $watermark,
int $offsetX,
int $offsetY,
int $opacity
): void;
Image\Adapter\Imagick¶
Class Source on GitHub
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";
}
Phalcon\Image\Adapter\AbstractAdapterPhalcon\Image\Adapter\Imagick
Uses Imagick · ImagickDraw · ImagickDrawException · ImagickException · ImagickPixel · ImagickPixelException · Phalcon\Image\Enum · Phalcon\Image\Exception · Phalcon\Image\Exceptions\CompositeFailed · Phalcon\Image\Exceptions\ExtensionNotLoaded · Phalcon\Image\Exceptions\ImageLoadFailed · Phalcon\Image\Exceptions\ResizeFailed · Phalcon\Image\Exceptions\ResourceTypeError
Method Summary¶
public __construct(string $file,int $width = null,int $height = null) Constructor public __destruct() Destroys the loaded image to free up resources. public AbstractAdapter liquidRescale(int $width,int $height,int $deltaX = 0,int $rigidity = 0) This method scales the images using liquid rescaling method. Only support public void setResourceLimit(int $type,int $limit) Sets the limit for a particular resource in megabytes protected void processBackground(int $red,int $green,int $blue,int $opacity) Execute a background. protected void processBlur( int $radius ) Blur image protected void processCrop(int $width,int $height,int $offsetX,int $offsetY) Execute a crop. protected void processFlip( int $direction ) Execute a flip. protected void processMask( AdapterInterface $image ) Composite one image onto another protected void processPixelate( int $amount ) Pixelate image protected void processReflection(int $height,int $opacity,bool $fadeIn) Execute a reflection. protected string processRender(string $extension,int $quality) Execute a render. protected void processResize(int $width,int $height) Execute a resize. protected void processRotate( int $degrees ) Execute a rotation. protected void processSave(string $file,int $quality) Execute a save. protected void processSharpen( int $amount ) Execute a sharpen. protected void processText(string $text,mixed $offsetX,mixed $offsetY,int $opacity,int $red,int $green,int $blue,int $size,string $fontFile = null) Execute a text protected void processWatermark(AdapterInterface $image,int $offsetX,int $offsetY,int $opacity) Add Watermark Properties¶
protected int $version = 0 Methods¶
__construct()¶
Constructor
__destruct()¶
Destroys the loaded image to free up resources.
liquidRescale()¶
public function liquidRescale(
int $width,
int $height,
int $deltaX = 0,
int $rigidity = 0
): AbstractAdapter;
This method scales the images using liquid rescaling method. Only support Imagick
setResourceLimit()¶
Sets the limit for a particular resource in megabytes
@link https://www.php.net/manual/en/imagick.constants.php#imagick.constants.resourcetypes
processBackground()¶
Execute a background.
processBlur()¶
Blur image
processCrop()¶
Execute a crop.
processFlip()¶
Execute a flip.
processMask()¶
Composite one image onto another
processPixelate()¶
Pixelate image
processReflection()¶
Execute a reflection.
processRender()¶
Execute a render.
processResize()¶
Execute a resize.
processRotate()¶
Execute a rotation.
processSave()¶
Execute a save.
processSharpen()¶
Execute a sharpen.
processText()¶
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
processWatermark()¶
protected function processWatermark(
AdapterInterface $image,
int $offsetX,
int $offsetY,
int $opacity
): void;
Add Watermark
Image\Enum¶
Class Source on GitHub
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.
Phalcon\Image\Enum
Constants¶
int AUTO = 4 int HEIGHT = 3 int HORIZONTAL = 11 int INVERSE = 5 int NONE = 1 int PRECISE = 6 int TENSILE = 7 int VERTICAL = 12 int WIDTH = 2 Image\Exception¶
Class Source on GitHub
Exceptions thrown in Phalcon\Image will use this class
\ExceptionPhalcon\Image\ExceptionPhalcon\Image\Exceptions\CompositeFailedPhalcon\Image\Exceptions\ExtensionNotLoadedPhalcon\Image\Exceptions\ImageLoadFailedPhalcon\Image\Exceptions\MissingDimensionsPhalcon\Image\Exceptions\MissingHeightPhalcon\Image\Exceptions\MissingWidthPhalcon\Image\Exceptions\ResizeFailedPhalcon\Image\Exceptions\ResourceTypeErrorPhalcon\Image\Exceptions\TextRenderingFailedPhalcon\Image\Exceptions\UnsupportedImageTypePhalcon\Image\Exceptions\VersionMismatch
Image\Exceptions\CompositeFailed¶
Class Source on GitHub
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.
\ExceptionPhalcon\Image\ExceptionPhalcon\Image\Exceptions\CompositeFailed
Uses Phalcon\Image\Exception
Method Summary¶
Methods¶
__construct()¶
Image\Exceptions\ExtensionNotLoaded¶
Class Source on GitHub
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.
\ExceptionPhalcon\Image\ExceptionPhalcon\Image\Exceptions\ExtensionNotLoaded
Uses Phalcon\Image\Exception
Method Summary¶
Methods¶
__construct()¶
Image\Exceptions\ImageLoadFailed¶
Class Source on GitHub
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.
\ExceptionPhalcon\Image\ExceptionPhalcon\Image\Exceptions\ImageLoadFailed
Uses Phalcon\Image\Exception
Method Summary¶
Methods¶
__construct()¶
Image\Exceptions\MissingDimensions¶
Class Source on GitHub
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.
\ExceptionPhalcon\Image\ExceptionPhalcon\Image\Exceptions\MissingDimensions
Uses Phalcon\Image\Exception
Method Summary¶
Methods¶
__construct()¶
Image\Exceptions\MissingHeight¶
Class Source on GitHub
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.
\ExceptionPhalcon\Image\ExceptionPhalcon\Image\Exceptions\MissingHeight
Uses Phalcon\Image\Exception
Method Summary¶
Methods¶
__construct()¶
Image\Exceptions\MissingWidth¶
Class Source on GitHub
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.
\ExceptionPhalcon\Image\ExceptionPhalcon\Image\Exceptions\MissingWidth
Uses Phalcon\Image\Exception
Method Summary¶
Methods¶
__construct()¶
Image\Exceptions\ResizeFailed¶
Class Source on GitHub
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.
\ExceptionPhalcon\Image\ExceptionPhalcon\Image\Exceptions\ResizeFailed
Uses Phalcon\Image\Exception
Method Summary¶
Methods¶
__construct()¶
Image\Exceptions\ResourceTypeError¶
Class Source on GitHub
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.
\ExceptionPhalcon\Image\ExceptionPhalcon\Image\Exceptions\ResourceTypeError
Uses Phalcon\Image\Exception
Method Summary¶
Methods¶
__construct()¶
Image\Exceptions\TextRenderingFailed¶
Class Source on GitHub
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.
\ExceptionPhalcon\Image\ExceptionPhalcon\Image\Exceptions\TextRenderingFailed
Uses Phalcon\Image\Exception
Method Summary¶
Methods¶
__construct()¶
Image\Exceptions\UnsupportedImageType¶
Class Source on GitHub
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.
\ExceptionPhalcon\Image\ExceptionPhalcon\Image\Exceptions\UnsupportedImageType
Uses Phalcon\Image\Exception
Method Summary¶
Methods¶
__construct()¶
Image\Exceptions\VersionMismatch¶
Class Source on GitHub
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.
\ExceptionPhalcon\Image\ExceptionPhalcon\Image\Exceptions\VersionMismatch
Uses Phalcon\Image\Exception
Method Summary¶
Methods¶
__construct()¶
Image\ImageFactory¶
Class Source on GitHub
Factory to create adapters for image manipulation
Phalcon\Factory\AbstractConfigFactoryPhalcon\Factory\AbstractFactoryPhalcon\Image\ImageFactory
Uses Phalcon\Config\ConfigInterface · Phalcon\Factory\AbstractFactory · Phalcon\Image\Adapter\AdapterInterface
Method Summary¶
public __construct( array $services = [] ) Constructor public AdapterInterface load( mixed $config ) Factory to create an instance from a Config object public AdapterInterface newInstance(string $name,string $file,int $width = null,int $height = null) Creates a new instance protected string getExceptionClass() protected array getServices() Returns the available adapters Methods¶
__construct()¶
Constructor
load()¶
Factory to create an instance from a Config object
newInstance()¶
public function newInstance(
string $name,
string $file,
int $width = null,
int $height = null
): AdapterInterface;
Creates a new instance
getExceptionClass()¶
getServices()¶
Returns the available adapters