Methods summary
public static
MvcCore\Ext\Tools\Image
|
#
CreateInstance( integer|MvcCore\Ext\Tools\Images\IAdapter $preferredAdapter = \MvcCore\Ext\Tools\Images\IAdapter::NONE )
Returns every time new (no singleton) \MvcCore\Ext\Tools\Image instance implementation.
If there is Imagick extension loaded and no $preferredAdapter presented,
Imagick instance is always created more preferably than GD instance.
If there is no Imagick and no GD extension loaded, new \RuntimeException exception is thrown.
Returns every time new (no singleton) \MvcCore\Ext\Tools\Image instance implementation.
If there is Imagick extension loaded and no $preferredAdapter presented,
Imagick instance is always created more preferably than GD instance.
If there is no Imagick and no GD extension loaded, new \RuntimeException exception is thrown.
Parameters
- $preferredAdapter
- optional
Returns
Throws
RuntimeException
|
public static
string
|
#
GetTmpDirPath( )
Get full directory path for temporary images computation.
If no temporary path configured, there is used default
system temporary directory from \MvcCore\Tool::GetSystemTmpDir(); .
Get full directory path for temporary images computation.
If no temporary path configured, there is used default
system temporary directory from \MvcCore\Tool::GetSystemTmpDir(); .
Returns
string
|
public static
|
#
SetTmpDirPath( string $fullPath )
Set custom full directory path for computation temporary images.
Set custom full directory path for computation temporary images.
Parameters
|
public static
array
|
#
HexColor2RgbArrayColor( string $hexColor )
Parameters
- $hexColor
- Color in hexadecimal format with or without leading hash.
Returns
array [$r, $g, $b, 'type' => 'RGB'];
|
public
integer
|
#
GetWidth( )
Get image pixel width.
Returns
integer
|
public
integer
|
#
GetHeight( )
Get image pixel height.
Returns
integer
|
public
MvcCore\Ext\Tools\Image
|
#
ResizeByWidth( integer $width )
Scale source image by width with maintaining the aspect ratio.
Scale source image by width with maintaining the aspect ratio.
Parameters
Returns
|
public
MvcCore\Ext\Tools\Image
|
#
ResizeByHeight( integer $height )
Scale source image by height with maintaining the aspect ratio.
Scale source image by height with maintaining the aspect ratio.
Parameters
Returns
|
public
MvcCore\Ext\Tools\Image
|
#
ResizeByPixelsCount( integer $resizedImgTotalPixelsCount )
Scale source image by total final count of pixels in the resized image.
Useful for list of logotypes, where is necessary to scale all logotypes into
the same visual space - with approximately the same importance by filled space,
so not resized by height or not by width, logotypes have always different proportions.
Scale source image by total final count of pixels in the resized image.
Useful for list of logotypes, where is necessary to scale all logotypes into
the same visual space - with approximately the same importance by filled space,
so not resized by height or not by width, logotypes have always different proportions.
Parameters
- $resizedImgTotalPixelsCount
Pixels count, computed by target width × height,
so if you want all images with approximately the same
size around 100 × 100 pixels, value will be 100 × 100 = 10000.
Returns
|
public
MvcCore\Ext\Tools\Image
|
#
Contain( integer $width, integer $height )
Image will be resized into sizes not larger than $width
or $height params with maintaining the aspect ratio.
Image will be resized into sizes not larger than $width
or $height params with maintaining the aspect ratio.
Parameters
- $width
- Pixel width.
- $height
- Pixel height.
Returns
|
public
MvcCore\Ext\Tools\Image
|
#
Cover( integer $width, integer $height, integer|MvcCore\Ext\Tools\Images\IOrientation $orientation = \MvcCore\Ext\Tools\Images\IOrientation::MIDDLE_CENTER )
Image will be resized into given $width and $height to cover whole place,
with optional orientation of source image to cover final place.
Possible orientation values are integers with this meaning:
- 1 - top left
- 2 - top center
- 3 - top right
- 4 - middle left
- 5 - middle center
- 6 - middle right
- 7 - bottom left
- 8 - bottom center
- 9 - bottom right
Image will be resized into given $width and $height to cover whole place,
with optional orientation of source image to cover final place.
Possible orientation values are integers with this meaning:
- 1 - top left
- 2 - top center
- 3 - top right
- 4 - middle left
- 5 - middle center
- 6 - middle right
- 7 - bottom left
- 8 - bottom center
- 9 - bottom right
Parameters
- $width
- Pixel width.
- $height
- Pixel height.
- $orientation
- Possible orientation values are integers by
\MvcCore\Ext\Tools\Images\IOrientation interface constants.
Returns
Throws
InvalidArgumentException
|
public
MvcCore\Ext\Tools\Image
|
#
CropPercent( integer $xPercentage, integer $yPercentage, integer $widthPercentage, integer $heightPercentage )
Crop image by percentage value from left, top, right and bottom.
Crop image by percentage value from left, top, right and bottom.
Parameters
- $xPercentage
- Percentage value to crop from left.
- $yPercentage
- Percentage value to crop from top.
- $widthPercentage
- Percentage value to crop from right.
- $heightPercentage
- Percentage value to crop from bottom.
Returns
|
public
boolean|MvcCore\Ext\Tools\Image
|
#
Load( string $imgFullPath )
Load image into resource by given file full path.
Load image into resource by given file full path.
Parameters
Returns
Throws
RuntimeException
|
public
MvcCore\Ext\Tools\Image
|
#
Save( string $fullPath, string|MvcCore\Ext\Tools\Images\IFormat $format = \MvcCore\Ext\Tools\Images\IFormat::PNG, integer $quality = NULL )
Save image in desired full path by format and optional quality settings.
Save image in desired full path by format and optional quality settings.
Parameters
- $fullPath
- $format
png by default.
- $quality
NULL by default - no quality settings will be used.
Returns
|
public
MvcCore\Ext\Tools\Image
|
#
Resize( integer $width, integer $height )
Resize image to desired with and height without maintaining the aspect ratio.
Resize image to desired with and height without maintaining the aspect ratio.
Parameters
- $width
- Pixel width.
- $height
- Pixel height.
Returns
|
public
MvcCore\Ext\Tools\Image
|
#
Crop( integer $x, integer $y, integer $width, integer $height )
Crop image from left, top right or bottom side.
Crop image from left, top right or bottom side.
Parameters
- $x
- Pixel size to crop from left.
- $y
- Pixel size to crop from top.
- $width
- Pixel size to crop from right.
- $height
- Pixel size to crop from bottom.
Returns
|
public
MvcCore\Ext\Tools\Image
|
#
Frame( integer $width, integer $height )
Image will be resized into sizes not larger than $width
or $height params with maintaining the aspect ratio and
places without image content will be filled with transparent
background color.
Image will be resized into sizes not larger than $width
or $height params with maintaining the aspect ratio and
places without image content will be filled with transparent
background color.
Parameters
- $width
- Pixel width.
- $height
- Pixel height.
Returns
|
public
MvcCore\Ext\Tools\Image
|
#
SetBackgroundColor( string $hexColor )
Set background color for prepared image.
Set background color for prepared image.
Parameters
- $hexColor
- Color in hexadecimal format with or without leading hash.
Returns
|
public
MvcCore\Ext\Tools\Image
|
#
UnsharpMask( integer $amount, float $radius, integer $threshold )
Apply to whole image Photoshop like Unsharp Mask filter to sharp image.
This method is very time consuming for GD image implementation!
Apply to whole image Photoshop like Unsharp Mask filter to sharp image.
This method is very time consuming for GD image implementation!
Parameters
- $amount
- Typically: 50 - 200, min. 0, max. 500.
- $radius
- Typically: 0.5 - 1, min. 0, max. 50.
- $threshold
- Typically: 0 - 5, min. 0, max. 255.
Returns
|
public
MvcCore\Ext\Tools\Image
|
#
ApplyMask( string $maskImgFullPath )
Apply to whole image Photoshop like Channel Mask.
Image given as first argument will be used as grayscale
channel mask applied to this image instance.
This method is very time consuming for GD image implementation!
Apply to whole image Photoshop like Channel Mask.
Image given as first argument will be used as grayscale
channel mask applied to this image instance.
This method is very time consuming for GD image implementation!
Parameters
Returns
Throws
InvalidArgumentException
|
public
MvcCore\Ext\Tools\Image
|
#
Grayscale( )
Convert whole image to grayscale.
Convert whole image to grayscale.
Returns
|
public
MvcCore\Ext\Tools\Image
|
#
Sepia( float $threshold = 80 )
Applies a special effect to the image, similar to the effect achieved
in a photo darkroom by sepia toning. Threshold ranges from 0 to QuantumRange
and is a measure of the extent of the sepia toning. A threshold of 80 is
a good starting point for a reasonable tone.
Applies a special effect to the image, similar to the effect achieved
in a photo darkroom by sepia toning. Threshold ranges from 0 to QuantumRange
and is a measure of the extent of the sepia toning. A threshold of 80 is
a good starting point for a reasonable tone.
Parameters
Returns
|
public
MvcCore\Ext\Tools\Image
|
#
RoundCorners( float $x, float $y )
Round image corners with the same x-round and y-round sizes.
This method is very time consuming for GD image implementation!
Round image corners with the same x-round and y-round sizes.
This method is very time consuming for GD image implementation!
Parameters
- $x
- X-rounding.
- $y
- Y-rounding.
Returns
|
public
MvcCore\Ext\Tools\Image
|
#
Rotate( float $angle, string $hexBgColor = 'transparent' )
Rotate image with optional background color, transparent by default.
Rotate image with optional background color, transparent by default.
Parameters
- $angle
- $hexBgColor
- Color in hexadecimal format with or without leading hash. Transparent by default.
Returns
|
public
MvcCore\Ext\Tools\Image
|
#
SetBackgroundImage( string $image )
Set background image. If background image has different sizes,
it's resized without maintaining the aspect ratio to the same
sizes as current image instance.
Set background image. If background image has different sizes,
it's resized without maintaining the aspect ratio to the same
sizes as current image instance.
Parameters
Returns
Throws
InvalidArgumentException
|
public
boolean
|
#
IsVectorGraphic( )
Return TRUE if image is vector graphic. FALSE otherwise.
Return always FALSE for GD images, GD library cannot work with vector graphics.
Return TRUE if image is vector graphic. FALSE otherwise.
Return always FALSE for GD images, GD library cannot work with vector graphics.
Returns
boolean
|
public
MvcCore\Ext\Tools\Image
|
#
AddOverlay( string $overlayImgFullPath, integer $x = 0, integer $y = 0, integer $alpha = NULL, integer|MvcCore\Ext\Tools\Images\IComposite $composite = \MvcCore\Ext\Tools\Images\IComposite::NORMAL )
Composite one image onto another at the specified offset.
Composite one image onto another at the specified offset.
Parameters
- $overlayImgFullPath
- $x
- $y
- $alpha
- $composite
Returns
Throws
InvalidArgumentException
See
http://php.net/manual/en/imagick.compositeimage.php
http://php.net/manual/en/imagick.constants.php#imagick.constants.composite-default
|
public
resource
|
#
CreateEmptyImageResource( integer $width, integer $height, string $hexBgColor = 'transparent' )
Create new empty image instance.
Create new empty image instance.
Parameters
- $width
- Pixel width.
- $height
- Pixel height.
- $hexBgColor
- Color in hexadecimal format with or without leading hash.
Returns
resource
|