PHP Class Pop\Image\AbstractImage

Author: Nick Sagona, III ([email protected])
Inheritance: implements Pop\Image\ImageInterface
Datei anzeigen Open project: nicksagona/PopPHP Class Usage Examples

Protected Properties

Property Type Description
$alpha boolean Image alpha
$backgroundColor mixed Image background color
$channels integer Image channels
$depth integer Image bit depth
$fillColor mixed Image fill color
$height integer Image height
$info ArrayObject Image extension info
$mode string Image mode
$quality integer | string Image quality
$resource resource Image resource
$strokeColor mixed Image stroke color
$strokeWidth integer Image stroke width
$width integer Image width

Public Methods

Method Description
__construct ( string $img, integer | string $w = null, integer | string $h = null, Pop\Color\Space\ColorInterface $color = null, array $types = null ) : AbstractImage Constructor
border ( integer $w, integer $h = null, integer $type = AbstractImage::INNER_BORDER ) : mixed Method to add a border to the image.
brightness ( integer $b ) : mixed Method to adjust the brightness of the image.
colorTotal ( ) : integer Return the number of colors in the palette of indexed images.
colorize ( Pop\Color\Space\ColorInterface $color ) : mixed Method to colorize the image with the color passed.
contrast ( integer $amount ) : mixed Method to adjust the contrast of the image.
convert ( string $type ) : mixed Convert the image object to the new specified image type.
crop ( integer | string $wid, integer | string $hgt, integer | string $x, integer | string $y ) : mixed Crop the image object to a image whose dimensions are based on the value of the $wid and $hgt argument. The optional $x and $y arguments allow for the adjustment of the crop to select a certain area of the image to be cropped.
cropThumb ( integer | string $px, integer | string $x, integer | string $y ) : mixed Crop the image object to a square image whose dimensions are based on the value of the $px argument. The optional $x and $y arguments allow for the adjustment of the crop to select a certain area of the image to be cropped. For example, if the values of $px = 50, $x = 20, $y = 0 are passed, then a 50px X 50px image will be created from the original image, with its origins starting at the (20, 0) x-y coordinates.
destroy ( boolean $file = false ) : void Destroy the image object and the related image file directly.
drawArc ( integer $x, integer $y, integer $start, integer $end, integer $w, integer $h = null ) : void Method to add an arc to the image.
drawCircle ( integer $x, integer $y, integer $w ) : void Method to add a circle to the image.
drawEllipse ( integer $x, integer $y, integer $w, integer $h = null ) : void Method to add an ellipse to the image.
drawLine ( integer $x1, integer $y1, integer $x2, integer $y2 ) : void Method to add a line to the image.
drawPolygon ( array $points ) : void Method to add a polygon to the image.
drawRectangle ( integer $x, integer $y, integer $w, integer $h = null ) : void Method to add a rectangle to the image.
drawSquare ( integer $x, integer $y, integer $w ) : void Method to add a square to the image.
getChannels ( ) : integer Get the number of image channels.
getColorMode ( ) : string Get the image color mode.
getColors ( string $format = 'HEX' ) : array Return all of the colors in the palette in an array format, omitting any repeats. It is strongly advised that this method only be used for smaller image files, preferably with small palettes, as any large images with many colors will cause this method to run slowly. Default format of the values in the returned array is the 6-digit HEX value, but if 'RGB' is passed, then the format of the values in the returned array will be 'R,G,B', i.e. '235,123,12'.
getDepth ( ) : integer Get the image bit depth.
getHeight ( ) : integer Get the image height.
getWidth ( ) : integer Get the image width.
hasAlpha ( ) : boolean Get whether or not the image has an alpha channel.
info ( ) : ArrayObject Get the image resource info
invert ( ) : mixed Method to invert the image (create a negative.)
overlay ( string $ovr, integer | string $x, integer | string $y ) : mixed Overlay an image onto the current image.
resize ( integer | string $px ) : mixed Resize the image object, allowing for the largest dimension to be scaled to the value of the $px argument. For example, if the value of $px = 200, and the image is 800px X 600px, then the image will be scaled to 200px X 150px.
resizeToHeight ( integer | string $hgt ) : mixed Resize the image object to the height parameter passed.
resizeToWidth ( integer | string $wid ) : mixed Resize the image object to the width parameter passed.
rotate ( integer | string $deg ) : mixed Rotate the image object, using simple degrees, i.e. -90, to rotate the image.
scale ( float | string $scl ) : mixed Scale the image object, allowing for the dimensions to be scaled proportionally to the value of the $scl argument. For example, if the value of $scl = 0.50, and the image is 800px X 600px, then the image will be scaled to 400px X 300px.
setBackgroundColor ( Pop\Color\Space\ColorInterface $color = null ) : mixed Set the background color.
setFillColor ( Pop\Color\Space\ColorInterface $color = null ) : mixed Set the fill color.
setOpacity ( integer | string $opac ) : mixed Set the opacity.
setQuality ( integer | string $q = null ) : mixed Set the image quality based on the type of image.
setStrokeColor ( Pop\Color\Space\ColorInterface $color = null ) : mixed Set the stroke color.
setStrokeWidth ( integer | string $wid = null ) : mixed Set the stroke width.
text ( string $str, integer | string $size, integer | string $x, integer | string $y, string $font = null, integer | string $rotate = null, boolean $stroke = false ) : mixed Create text within the an image object. A font file can be used for the font argument. The size, rotation and position can be set by those arguments.

Protected Methods

Method Description
setColor ( Pop\Color\Space\ColorInterface $color = null ) : mixed Set and return a color identifier.

Method Details

__construct() public method

Instantiate an image file object based on either a pre-existing image file on disk, or a new image file.
public __construct ( string $img, integer | string $w = null, integer | string $h = null, Pop\Color\Space\ColorInterface $color = null, array $types = null ) : AbstractImage
$img string
$w integer | string
$h integer | string
$color Pop\Color\Space\ColorInterface
$types array
return AbstractImage

border() abstract public method

Method to add a border to the image.
abstract public border ( integer $w, integer $h = null, integer $type = AbstractImage::INNER_BORDER ) : mixed
$w integer
$h integer
$type integer
return mixed

brightness() abstract public method

Method to adjust the brightness of the image.
abstract public brightness ( integer $b ) : mixed
$b integer
return mixed

colorTotal() abstract public method

Returns 0 for true color images.
abstract public colorTotal ( ) : integer
return integer

colorize() abstract public method

Method to colorize the image with the color passed.
abstract public colorize ( Pop\Color\Space\ColorInterface $color ) : mixed
$color Pop\Color\Space\ColorInterface
return mixed

contrast() abstract public method

Method to adjust the contrast of the image.
abstract public contrast ( integer $amount ) : mixed
$amount integer
return mixed

convert() abstract public method

Convert the image object to the new specified image type.
abstract public convert ( string $type ) : mixed
$type string
return mixed

crop() abstract public method

Crop the image object to a image whose dimensions are based on the value of the $wid and $hgt argument. The optional $x and $y arguments allow for the adjustment of the crop to select a certain area of the image to be cropped.
abstract public crop ( integer | string $wid, integer | string $hgt, integer | string $x, integer | string $y ) : mixed
$wid integer | string
$hgt integer | string
$x integer | string
$y integer | string
return mixed

cropThumb() abstract public method

Crop the image object to a square image whose dimensions are based on the value of the $px argument. The optional $x and $y arguments allow for the adjustment of the crop to select a certain area of the image to be cropped. For example, if the values of $px = 50, $x = 20, $y = 0 are passed, then a 50px X 50px image will be created from the original image, with its origins starting at the (20, 0) x-y coordinates.
abstract public cropThumb ( integer | string $px, integer | string $x, integer | string $y ) : mixed
$px integer | string
$x integer | string
$y integer | string
return mixed

destroy() abstract public method

Destroy the image object and the related image file directly.
abstract public destroy ( boolean $file = false ) : void
$file boolean
return void

drawArc() abstract public method

Method to add an arc to the image.
abstract public drawArc ( integer $x, integer $y, integer $start, integer $end, integer $w, integer $h = null ) : void
$x integer
$y integer
$start integer
$end integer
$w integer
$h integer
return void

drawCircle() abstract public method

Method to add a circle to the image.
abstract public drawCircle ( integer $x, integer $y, integer $w ) : void
$x integer
$y integer
$w integer
return void

drawEllipse() abstract public method

Method to add an ellipse to the image.
abstract public drawEllipse ( integer $x, integer $y, integer $w, integer $h = null ) : void
$x integer
$y integer
$w integer
$h integer
return void

drawLine() abstract public method

Method to add a line to the image.
abstract public drawLine ( integer $x1, integer $y1, integer $x2, integer $y2 ) : void
$x1 integer
$y1 integer
$x2 integer
$y2 integer
return void

drawPolygon() abstract public method

Method to add a polygon to the image.
abstract public drawPolygon ( array $points ) : void
$points array
return void

drawRectangle() abstract public method

Method to add a rectangle to the image.
abstract public drawRectangle ( integer $x, integer $y, integer $w, integer $h = null ) : void
$x integer
$y integer
$w integer
$h integer
return void

drawSquare() abstract public method

Method to add a square to the image.
abstract public drawSquare ( integer $x, integer $y, integer $w ) : void
$x integer
$y integer
$w integer
return void

getChannels() public method

Get the number of image channels.
public getChannels ( ) : integer
return integer

getColorMode() public method

Get the image color mode.
public getColorMode ( ) : string
return string

getColors() abstract public method

Return all of the colors in the palette in an array format, omitting any repeats. It is strongly advised that this method only be used for smaller image files, preferably with small palettes, as any large images with many colors will cause this method to run slowly. Default format of the values in the returned array is the 6-digit HEX value, but if 'RGB' is passed, then the format of the values in the returned array will be 'R,G,B', i.e. '235,123,12'.
abstract public getColors ( string $format = 'HEX' ) : array
$format string
return array

getDepth() public method

Get the image bit depth.
public getDepth ( ) : integer
return integer

getHeight() public method

Get the image height.
public getHeight ( ) : integer
return integer

getWidth() public method

Get the image width.
public getWidth ( ) : integer
return integer

hasAlpha() public method

Get whether or not the image has an alpha channel.
public hasAlpha ( ) : boolean
return boolean

info() public method

Get the image resource info
public info ( ) : ArrayObject
return ArrayObject

invert() abstract public method

Method to invert the image (create a negative.)
abstract public invert ( ) : mixed
return mixed

overlay() abstract public method

Overlay an image onto the current image.
abstract public overlay ( string $ovr, integer | string $x, integer | string $y ) : mixed
$ovr string
$x integer | string
$y integer | string
return mixed

resize() abstract public method

Resize the image object, allowing for the largest dimension to be scaled to the value of the $px argument. For example, if the value of $px = 200, and the image is 800px X 600px, then the image will be scaled to 200px X 150px.
abstract public resize ( integer | string $px ) : mixed
$px integer | string
return mixed

resizeToHeight() abstract public method

Resize the image object to the height parameter passed.
abstract public resizeToHeight ( integer | string $hgt ) : mixed
$hgt integer | string
return mixed

resizeToWidth() abstract public method

Resize the image object to the width parameter passed.
abstract public resizeToWidth ( integer | string $wid ) : mixed
$wid integer | string
return mixed

rotate() abstract public method

Rotate the image object, using simple degrees, i.e. -90, to rotate the image.
abstract public rotate ( integer | string $deg ) : mixed
$deg integer | string
return mixed

scale() abstract public method

Scale the image object, allowing for the dimensions to be scaled proportionally to the value of the $scl argument. For example, if the value of $scl = 0.50, and the image is 800px X 600px, then the image will be scaled to 400px X 300px.
abstract public scale ( float | string $scl ) : mixed
$scl float | string
return mixed

setBackgroundColor() public method

Set the background color.
public setBackgroundColor ( Pop\Color\Space\ColorInterface $color = null ) : mixed
$color Pop\Color\Space\ColorInterface
return mixed

setColor() abstract protected method

Set and return a color identifier.
abstract protected setColor ( Pop\Color\Space\ColorInterface $color = null ) : mixed
$color Pop\Color\Space\ColorInterface
return mixed

setFillColor() public method

Set the fill color.
public setFillColor ( Pop\Color\Space\ColorInterface $color = null ) : mixed
$color Pop\Color\Space\ColorInterface
return mixed

setOpacity() abstract public method

Set the opacity.
abstract public setOpacity ( integer | string $opac ) : mixed
$opac integer | string
return mixed

setQuality() abstract public method

Set the image quality based on the type of image.
abstract public setQuality ( integer | string $q = null ) : mixed
$q integer | string
return mixed

setStrokeColor() public method

Set the stroke color.
public setStrokeColor ( Pop\Color\Space\ColorInterface $color = null ) : mixed
$color Pop\Color\Space\ColorInterface
return mixed

setStrokeWidth() public method

Set the stroke width.
public setStrokeWidth ( integer | string $wid = null ) : mixed
$wid integer | string
return mixed

text() abstract public method

Create text within the an image object. A font file can be used for the font argument. The size, rotation and position can be set by those arguments.
abstract public text ( string $str, integer | string $size, integer | string $x, integer | string $y, string $font = null, integer | string $rotate = null, boolean $stroke = false ) : mixed
$str string
$size integer | string
$x integer | string
$y integer | string
$font string
$rotate integer | string
$stroke boolean
return mixed

Property Details

$alpha protected_oe property

Image alpha
protected bool $alpha
return boolean

$backgroundColor protected_oe property

Image background color
protected mixed $backgroundColor
return mixed

$channels protected_oe property

Image channels
protected int $channels
return integer

$depth protected_oe property

Image bit depth
protected int $depth
return integer

$fillColor protected_oe property

Image fill color
protected mixed $fillColor
return mixed

$height protected_oe property

Image height
protected int $height
return integer

$info protected_oe property

Image extension info
protected ArrayObject $info
return ArrayObject

$mode protected_oe property

Image mode
protected string $mode
return string

$quality protected_oe property

Image quality
protected int|string $quality
return integer | string

$resource protected_oe property

Image resource
protected resource $resource
return resource

$strokeColor protected_oe property

Image stroke color
protected mixed $strokeColor
return mixed

$strokeWidth protected_oe property

Image stroke width
protected int $strokeWidth
return integer

$width protected_oe property

Image width
protected int $width
return integer