PHP Class Pop\Image\Gd

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

Protected Properties

Свойство Type Description
$allowed array Array of allowed file types.
$opacity integer Image color opacity

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 ) : Gd Constructor
__destruct ( ) : void Destructor to destroy the image resource
__toString ( ) : string To string method to output the image
blur ( integer $amount, integer $type = Gd::GAUSSIAN_BLUR ) : Gd Method to blur the image.
border ( integer $w, integer $h = null, integer $type = Gd::INNER_BORDER ) : Gd Method to add a border to the image.
brightness ( integer $b ) : Gd 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 ) : Gd Method to colorize the image with the color passed.
contrast ( integer $amount ) : Gd Method to adjust the contrast of the image.
convert ( string $type ) : Gd 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
cropThumb ( integer | string $px, integer | string $x, integer | string $y ) : Gd Crop the image object to a square image
desaturate ( ) : Gd Method to desaturate the image.
destroy ( boolean $file = false ) : void Destroy the image object and the related image file directly.
diffuse ( integer $radius ) : Gd Dummy method to match the Imagick API.
drawArc ( integer $x, integer $y, integer $start, integer $end, integer $w, integer $h = null ) : Gd Method to add an arc to the image.
drawCircle ( integer $x, integer $y, integer $w ) : Gd Method to add a circle to the image.
drawEllipse ( integer $x, integer $y, integer $w, integer $h = null ) : Gd Method to add an ellipse to the image.
drawLine ( integer $x1, integer $y1, integer $x2, integer $y2 ) : Gd Method to add a line to the image.
drawPolygon ( array $points ) : Gd Method to add a polygon to the image.
drawRectangle ( integer $x, integer $y, integer $w, integer $h = null ) : Gd Method to add a rectangle to the image.
drawSquare ( integer $x, integer $y, integer $w ) : Gd Method to add a square to the image.
flatten ( ) : Gd Dummy method to match the Imagick API.
flip ( ) : Gd Method to flip the image over the x-axis.
flop ( ) : Gd Method to flip the image over the y-axis.
formats ( ) : array Get formats
getColors ( integer | string $format = Pop\Image\Gd::HEX ) : array Return all of the colors in the palette in an array format
getFormats ( ) : array Get the array of supported formats of Imagick.
getNumberOfFormats ( ) : integer Get the number of supported formats of Imagick.
hsb ( integer $h, integer $s, integer $b ) : Gd Dummy method to match the Imagick API.
hue ( integer $h ) : Gd Dummy method to match the Imagick API.
invert ( ) : Gd Method to invert the image (create a negative.)
isInstalled ( ) : boolean Check if GD is installed.
level ( integer $black, float $gamma, integer $white ) : Gd Dummy method to match the Imagick API.
noise ( integer $type ) : Gd Dummy method to match the Imagick API.
output ( boolean $download = false ) : Gd Output the image object directly.
overlay ( string $ovr, integer | string $x, integer | string $y ) : Gd Overlay an image onto the current image.
paint ( integer $radius ) : Gd Dummy method to match the Imagick API.
pencil ( ) : Gd Apply a pencil/sketch effect to the image
pixelate ( integer $px ) : Gd Apply a mosiac pixelate effect to the image
posterize ( integer $levels, boolean $dither = false ) : Gd Dummy method to match the Imagick API.
resize ( integer | string $px ) : Gd Resize the image object to the largest dimension
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.
resource ( ) : resource Get the image resource to directly interact with it
rotate ( integer | string $deg ) : Gd Rotate the image object, using simple degrees, i.e. -90, to rotate the image.
saturation ( integer $s ) : Gd Dummy method to match the Imagick API.
save ( string $to = null, boolean $append = false ) : Gd Save the image object to disk.
scale ( float | string $scl ) : Gd Scale the image object
setBlur ( integer | string $blur = null ) : Imagick Dummy method to match the Imagick API.
setCompression ( mixed $comp = null ) : Imagick Set the image compression quality.
setFilter ( integer | string $filter = null ) : Gd Dummy method to match the Imagick API.
setFormats ( ) : Gd Dummy method to match the Imagick API.
setOpacity ( integer | string $opac ) : Gd Set the opacity.
setOverlay ( integer | string $ovr = null ) : Imagick Dummy method to match the Imagick API.
setQuality ( mixed $q = null ) : Gd Set the image quality based on the type of image.
sharpen ( integer $amount ) : Gd Method to sharpen the image.
skew ( Pop\Color\Space\ColorInterface $color, integer $x, integer $y ) : Gd Dummy method to match the Imagick API.
swirl ( integer $degrees ) : Gd Dummy method to match the Imagick API.
text ( string $str, integer | string $size, integer | string $x, integer | string $y, string $font = null, integer | string $rotate = null, boolean $stroke = false ) : Gd Create text within the an image object
wave ( integer $amp, integer $length ) : Gd Dummy method to match the Imagick API.

Méthodes protégées

Méthode Description
copyImage ( integer | string $w, integer | string $h, integer | string $x, integer | string $y ) : void Copy the image resource to the image output resource with the set parameters.
createImage ( string $new, string $img = null, integer | string $q = null ) : void Create and save the new image file in the correct format.
createResource ( ) : void Create a new image resource based on the current image type of the image object.
getInfo ( ) : void Get GD Info.
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 ) : Gd
$img string
$w integer | string
$h integer | string
$color Pop\Color\Space\ColorInterface
$types array
Résultat Gd

__destruct() public méthode

Destructor to destroy the image resource
public __destruct ( ) : void
Résultat void

__toString() public méthode

To string method to output the image
public __toString ( ) : string
Résultat string

blur() public méthode

Method to blur the image.
public blur ( integer $amount, integer $type = Gd::GAUSSIAN_BLUR ) : Gd
$amount integer
$type integer
Résultat Gd

border() public méthode

Method to add a border to the image.
public border ( integer $w, integer $h = null, integer $type = Gd::INNER_BORDER ) : Gd
$w integer
$h integer
$type integer
Résultat Gd

brightness() public méthode

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

colorTotal() public méthode

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

colorize() public méthode

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

contrast() public méthode

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

convert() public méthode

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

copyImage() protected méthode

Copy the image resource to the image output resource with the set parameters.
protected copyImage ( integer | string $w, integer | string $h, integer | string $x, integer | string $y ) : void
$w integer | string
$h integer | string
$x integer | string
$y integer | string
Résultat void

createImage() protected méthode

Create and save the new image file in the correct format.
protected createImage ( string $new, string $img = null, integer | string $q = null ) : void
$new string
$img string
$q integer | string
Résultat void

createResource() protected méthode

Create a new image resource based on the current image type of the image object.
protected createResource ( ) : void
Résultat void

crop() public méthode

Crop the image object
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() public méthode

Crop the image object to a square image
public cropThumb ( integer | string $px, integer | string $x, integer | string $y ) : Gd
$px integer | string
$x integer | string
$y integer | string
Résultat Gd

desaturate() public méthode

Method to desaturate the image.
public desaturate ( ) : Gd
Résultat Gd

destroy() public méthode

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

diffuse() public méthode

This method doesn't do anything
public diffuse ( integer $radius ) : Gd
$radius integer
Résultat Gd

drawArc() public méthode

Method to add an arc to the image.
public drawArc ( integer $x, integer $y, integer $start, integer $end, integer $w, integer $h = null ) : Gd
$x integer
$y integer
$start integer
$end integer
$w integer
$h integer
Résultat Gd

drawCircle() public méthode

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

drawEllipse() public méthode

Method to add an ellipse to the image.
public drawEllipse ( integer $x, integer $y, integer $w, integer $h = null ) : Gd
$x integer
$y integer
$w integer
$h integer
Résultat Gd

drawLine() public méthode

Method to add a line to the image.
public drawLine ( integer $x1, integer $y1, integer $x2, integer $y2 ) : Gd
$x1 integer
$y1 integer
$x2 integer
$y2 integer
Résultat Gd

drawPolygon() public méthode

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

drawRectangle() public méthode

Method to add a rectangle to the image.
public drawRectangle ( integer $x, integer $y, integer $w, integer $h = null ) : Gd
$x integer
$y integer
$w integer
$h integer
Résultat Gd

drawSquare() public méthode

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

flatten() public méthode

This method doesn't do anything
public flatten ( ) : Gd
Résultat Gd

flip() public méthode

Method to flip the image over the x-axis.
public flip ( ) : Gd
Résultat Gd

flop() public méthode

Method to flip the image over the y-axis.
public flop ( ) : Gd
Résultat Gd

formats() public static méthode

Get formats
public static formats ( ) : array
Résultat array

getColors() public méthode

Return all of the colors in the palette in an array format
public getColors ( integer | string $format = Pop\Image\Gd::HEX ) : array
$format integer | string
Résultat array

getFormats() public méthode

Get the array of supported formats of Imagick.
public getFormats ( ) : array
Résultat array

getInfo() protected méthode

Get GD Info.
protected getInfo ( ) : void
Résultat void

getNumberOfFormats() public méthode

Get the number of supported formats of Imagick.
public getNumberOfFormats ( ) : integer
Résultat integer

hsb() public méthode

This method doesn't do anything
public hsb ( integer $h, integer $s, integer $b ) : Gd
$h integer
$s integer
$b integer
Résultat Gd

hue() public méthode

This method doesn't do anything
public hue ( integer $h ) : Gd
$h integer
Résultat Gd

invert() public méthode

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

isInstalled() public static méthode

Check if GD is installed.
public static isInstalled ( ) : boolean
Résultat boolean

level() public méthode

This method doesn't do anything
public level ( integer $black, float $gamma, integer $white ) : Gd
$black integer
$gamma float
$white integer
Résultat Gd

noise() public méthode

This method doesn't do anything
public noise ( integer $type ) : Gd
$type integer
Résultat Gd

output() public méthode

Output the image object directly.
public output ( boolean $download = false ) : Gd
$download boolean
Résultat Gd

overlay() public méthode

Overlay an image onto the current image.
public overlay ( string $ovr, integer | string $x, integer | string $y ) : Gd
$ovr string
$x integer | string
$y integer | string
Résultat Gd

paint() public méthode

This method doesn't do anything
public paint ( integer $radius ) : Gd
$radius integer
Résultat Gd

pencil() public méthode

Apply a pencil/sketch effect to the image
public pencil ( ) : Gd
Résultat Gd

pixelate() public méthode

Apply a mosiac pixelate effect to the image
public pixelate ( integer $px ) : Gd
$px integer
Résultat Gd

posterize() public méthode

This method doesn't do anything
public posterize ( integer $levels, boolean $dither = false ) : Gd
$levels integer
$dither boolean
Résultat Gd

resize() public méthode

Resize the image object to the largest dimension
public resize ( integer | string $px ) : Gd
$px integer | string
Résultat Gd

resizeToHeight() public méthode

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

resizeToWidth() public méthode

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

resource() public méthode

Get the image resource to directly interact with it
public resource ( ) : resource
Résultat resource

rotate() public méthode

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

saturation() public méthode

This method doesn't do anything
public saturation ( integer $s ) : Gd
$s integer
Résultat Gd

save() public méthode

Save the image object to disk.
public save ( string $to = null, boolean $append = false ) : Gd
$to string
$append boolean
Résultat Gd

scale() public méthode

Scale the image object
public scale ( float | string $scl ) : Gd
$scl float | string
Résultat Gd

setBlur() public méthode

This method doesn't do anything
public setBlur ( integer | string $blur = null ) : Imagick
$blur integer | string
Résultat Imagick

setColor() protected méthode

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

setCompression() public méthode

Alias to setQuality()
public setCompression ( mixed $comp = null ) : Imagick
$comp mixed
Résultat Imagick

setFilter() public méthode

This method doesn't do anything
public setFilter ( integer | string $filter = null ) : Gd
$filter integer | string
Résultat Gd

setFormats() public méthode

This method doesn't do anything
public setFormats ( ) : Gd
Résultat Gd

setOpacity() public méthode

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

setOverlay() public méthode

This method doesn't do anything
public setOverlay ( integer | string $ovr = null ) : Imagick
$ovr integer | string
Résultat Imagick

setQuality() public méthode

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

sharpen() public méthode

Method to sharpen the image.
public sharpen ( integer $amount ) : Gd
$amount integer
Résultat Gd

skew() public méthode

This method doesn't do anything
public skew ( Pop\Color\Space\ColorInterface $color, integer $x, integer $y ) : Gd
$color Pop\Color\Space\ColorInterface
$x integer
$y integer
Résultat Gd

swirl() public méthode

This method doesn't do anything
public swirl ( integer $degrees ) : Gd
$degrees integer
Résultat Gd

text() public méthode

Create text within the an image object
public text ( string $str, integer | string $size, integer | string $x, integer | string $y, string $font = null, integer | string $rotate = null, boolean $stroke = false ) : Gd
$str string
$size integer | string
$x integer | string
$y integer | string
$font string
$rotate integer | string
$stroke boolean
Résultat Gd

wave() public méthode

This method doesn't do anything
public wave ( integer $amp, integer $length ) : Gd
$amp integer
$length integer
Résultat Gd

Property Details

$allowed protected_oe property

Array of allowed file types.
protected array $allowed
Résultat array

$opacity protected_oe property

Image color opacity
protected int $opacity
Résultat integer