PHP Class Pop\Image\AbstractImage

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

Protected Properties

Свойство 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

Méthodes publiques

Méthode 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.

Méthodes protégées

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

Method Details

__construct() public méthode

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
Résultat AbstractImage

border() abstract public méthode

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
Résultat mixed

brightness() abstract public méthode

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

colorTotal() abstract public méthode

Returns 0 for true color images.
abstract public colorTotal ( ) : integer
Résultat integer

colorize() abstract public méthode

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

contrast() abstract public méthode

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

convert() abstract public méthode

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

crop() abstract public méthode

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
Résultat mixed

cropThumb() abstract public méthode

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
Résultat mixed

destroy() abstract public méthode

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

drawArc() abstract public méthode

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
Résultat void

drawCircle() abstract public méthode

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

drawEllipse() abstract public méthode

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
Résultat void

drawLine() abstract public méthode

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
Résultat void

drawPolygon() abstract public méthode

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

drawRectangle() abstract public méthode

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
Résultat void

drawSquare() abstract public méthode

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

getChannels() public méthode

Get the number of image channels.
public getChannels ( ) : integer
Résultat integer

getColorMode() public méthode

Get the image color mode.
public getColorMode ( ) : string
Résultat string

getColors() abstract public méthode

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
Résultat array

getDepth() public méthode

Get the image bit depth.
public getDepth ( ) : integer
Résultat integer

getHeight() public méthode

Get the image height.
public getHeight ( ) : integer
Résultat integer

getWidth() public méthode

Get the image width.
public getWidth ( ) : integer
Résultat integer

hasAlpha() public méthode

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

info() public méthode

Get the image resource info
public info ( ) : ArrayObject
Résultat ArrayObject

invert() abstract public méthode

Method to invert the image (create a negative.)
abstract public invert ( ) : mixed
Résultat mixed

overlay() abstract public méthode

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
Résultat mixed

resize() abstract public méthode

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
Résultat mixed

resizeToHeight() abstract public méthode

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

resizeToWidth() abstract public méthode

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

rotate() abstract public méthode

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

scale() abstract public méthode

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
Résultat mixed

setBackgroundColor() public méthode

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

setColor() abstract protected méthode

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

setFillColor() public méthode

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

setOpacity() abstract public méthode

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

setQuality() abstract public méthode

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

setStrokeColor() public méthode

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

setStrokeWidth() public méthode

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

text() abstract public méthode

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
Résultat mixed

Property Details

$alpha protected_oe property

Image alpha
protected bool $alpha
Résultat boolean

$backgroundColor protected_oe property

Image background color
protected mixed $backgroundColor
Résultat mixed

$channels protected_oe property

Image channels
protected int $channels
Résultat integer

$depth protected_oe property

Image bit depth
protected int $depth
Résultat integer

$fillColor protected_oe property

Image fill color
protected mixed $fillColor
Résultat mixed

$height protected_oe property

Image height
protected int $height
Résultat integer

$info protected_oe property

Image extension info
protected ArrayObject $info
Résultat ArrayObject

$mode protected_oe property

Image mode
protected string $mode
Résultat string

$quality protected_oe property

Image quality
protected int|string $quality
Résultat integer | string

$resource protected_oe property

Image resource
protected resource $resource
Résultat resource

$strokeColor protected_oe property

Image stroke color
protected mixed $strokeColor
Résultat mixed

$strokeWidth protected_oe property

Image stroke width
protected int $strokeWidth
Résultat integer

$width protected_oe property

Image width
protected int $width
Résultat integer