PHP Class JBZoo\Utils\Image

Datei anzeigen Open project: jbzoo/utils Class Usage Examples

Public Methods

Method Description
addAlpha ( mixed $image, boolean $isBlend = true ) Add alpha chanel to image resource
alpha ( integer $color ) : integer
blur ( string $blur ) : integer
brightness ( integer $brightness ) : integer
checkGD ( boolean $thowException = true ) : boolean Require GD library
color ( integer $color ) : integer
colorize ( integer $colorize ) : integer
contrast ( integer $contrast ) : integer
direction ( string $direction ) : string
getInnerCoords ( string $position, array $canvas, array $box, array $offset = [0, 0] ) : array Determine position
imageCopyMergeAlpha ( mixed $dstImg, mixed $srcImg, array $dist, array $src, array $srcSizes, integer $opacity ) Same as PHP's imagecopymerge() function, except preserves alpha-transparency in 24-bit PNGs
isGdRes ( mixed $image ) : boolean Check is var image GD resource
isGif ( string $format ) : boolean
isJpeg ( string $format ) : boolean
isPng ( string $format ) : boolean
isSupportedFormat ( string $format ) : boolean Check is format supported by lib
normalizeColor ( string | array $origColor ) : integer[] Converts a hex color value to its RGB equivalent
opacity ( $opacity ) : integer Check opacity value
opacity2Alpha ( integer $opacity ) : integer Convert opacity value to alpha
percent ( string $percent ) : integer
position ( string $position ) : string Check position name
quality ( string $percent ) : integer
range ( mixed $value, integer $min, integer $max ) : integer Ensures $value is always within $min and $max range.
rotate ( integer $color ) : integer
smooth ( integer $smooth ) : integer
strToBin ( $imageString ) : string Convert string to binary data

Protected Methods

Method Description
_normalizeColorArray ( array $origColor ) : integer[] Normalize color from array
_normalizeColorString ( string $origColor ) : integer[] Normalize color from string

Method Details

_normalizeColorArray() protected static method

Normalize color from array
protected static _normalizeColorArray ( array $origColor ) : integer[]
$origColor array
return integer[]

_normalizeColorString() protected static method

Normalize color from string
protected static _normalizeColorString ( string $origColor ) : integer[]
$origColor string
return integer[]

addAlpha() public static method

Add alpha chanel to image resource
public static addAlpha ( mixed $image, boolean $isBlend = true )
$image mixed Image GD resource
$isBlend boolean Add alpha blending

alpha() public static method

public static alpha ( integer $color ) : integer
$color integer
return integer

blur() public static method

public static blur ( string $blur ) : integer
$blur string
return integer

brightness() public static method

public static brightness ( integer $brightness ) : integer
$brightness integer
return integer

checkGD() public static method

Require GD library
public static checkGD ( boolean $thowException = true ) : boolean
$thowException boolean
return boolean

color() public static method

public static color ( integer $color ) : integer
$color integer
return integer

colorize() public static method

public static colorize ( integer $colorize ) : integer
$colorize integer
return integer

contrast() public static method

public static contrast ( integer $contrast ) : integer
$contrast integer
return integer

direction() public static method

public static direction ( string $direction ) : string
$direction string
return string

getInnerCoords() public static method

Determine position
public static getInnerCoords ( string $position, array $canvas, array $box, array $offset = [0, 0] ) : array
$position string Position name or code
$canvas array Width and Height of canvas
$box array Width and Height of box that will be located on canvas
$offset array Forced offset X, Y
return array

imageCopyMergeAlpha() public static method

Same as PHP's imagecopymerge() function, except preserves alpha-transparency in 24-bit PNGs
public static imageCopyMergeAlpha ( mixed $dstImg, mixed $srcImg, array $dist, array $src, array $srcSizes, integer $opacity )
$dstImg mixed Dist image resource
$srcImg mixed Source image resource
$dist array Left and Top offset of dist
$src array Left and Top offset of source
$srcSizes array Width and Height of source
$opacity integer

isGdRes() public static method

Check is var image GD resource
public static isGdRes ( mixed $image ) : boolean
$image mixed
return boolean

isGif() public static method

public static isGif ( string $format ) : boolean
$format string
return boolean

isJpeg() public static method

public static isJpeg ( string $format ) : boolean
$format string
return boolean

isPng() public static method

public static isPng ( string $format ) : boolean
$format string
return boolean

isSupportedFormat() public static method

Check is format supported by lib
public static isSupportedFormat ( string $format ) : boolean
$format string
return boolean

normalizeColor() public static method

Converts a hex color value to its RGB equivalent
public static normalizeColor ( string | array $origColor ) : integer[]
$origColor string | array Hex color string, array(red, green, blue) or array(red, green, blue, alpha). Where red, green, blue - integers 0-255, alpha - integer 0-127
return integer[]

opacity() public static method

Check opacity value
public static opacity ( $opacity ) : integer
$opacity
return integer

opacity2Alpha() public static method

Convert opacity value to alpha
public static opacity2Alpha ( integer $opacity ) : integer
$opacity integer
return integer

percent() public static method

public static percent ( string $percent ) : integer
$percent string
return integer

position() public static method

Check position name
public static position ( string $position ) : string
$position string
return string

quality() public static method

public static quality ( string $percent ) : integer
$percent string
return integer

range() public static method

If lower, $min is returned. If higher, $max is returned.
public static range ( mixed $value, integer $min, integer $max ) : integer
$value mixed
$min integer
$max integer
return integer

rotate() public static method

public static rotate ( integer $color ) : integer
$color integer
return integer

smooth() public static method

public static smooth ( integer $smooth ) : integer
$smooth integer
return integer

strToBin() public static method

Convert string to binary data
public static strToBin ( $imageString ) : string
$imageString
return string