PHP Class Pop\Image\Gd

Author: Nick Sagona, III ([email protected])
Inheritance: extends Pop\Image\AbstractRasterImage
显示文件 Open project: nicksagona/PopPHP Class Usage Examples

Protected Properties

Property Type Description
$allowed array Array of allowed file types.
$opacity integer Image color opacity

Public Methods

Method 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.

Protected Methods

Method 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 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 ) : Gd
$img string
$w integer | string
$h integer | string
$color Pop\Color\Space\ColorInterface
$types array
return Gd

__destruct() public method

Destructor to destroy the image resource
public __destruct ( ) : void
return void

__toString() public method

To string method to output the image
public __toString ( ) : string
return string

blur() public method

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

border() public method

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
return Gd

brightness() public method

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

colorTotal() public method

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

colorize() public method

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

contrast() public method

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

convert() public method

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

copyImage() protected method

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
return void

createImage() protected method

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
return void

createResource() protected method

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

crop() public method

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
return mixed

cropThumb() public method

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
return Gd

desaturate() public method

Method to desaturate the image.
public desaturate ( ) : Gd
return Gd

destroy() public method

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

diffuse() public method

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

drawArc() public method

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
return Gd

drawCircle() public method

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

drawEllipse() public method

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
return Gd

drawLine() public method

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
return Gd

drawPolygon() public method

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

drawRectangle() public method

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
return Gd

drawSquare() public method

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

flatten() public method

This method doesn't do anything
public flatten ( ) : Gd
return Gd

flip() public method

Method to flip the image over the x-axis.
public flip ( ) : Gd
return Gd

flop() public method

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

formats() public static method

Get formats
public static formats ( ) : array
return array

getColors() public method

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
return array

getFormats() public method

Get the array of supported formats of Imagick.
public getFormats ( ) : array
return array

getInfo() protected method

Get GD Info.
protected getInfo ( ) : void
return void

getNumberOfFormats() public method

Get the number of supported formats of Imagick.
public getNumberOfFormats ( ) : integer
return integer

hsb() public method

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

hue() public method

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

invert() public method

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

isInstalled() public static method

Check if GD is installed.
public static isInstalled ( ) : boolean
return boolean

level() public method

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

noise() public method

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

output() public method

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

overlay() public method

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
return Gd

paint() public method

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

pencil() public method

Apply a pencil/sketch effect to the image
public pencil ( ) : Gd
return Gd

pixelate() public method

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

posterize() public method

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

resize() public method

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

resizeToHeight() public method

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

resizeToWidth() public method

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

resource() public method

Get the image resource to directly interact with it
public resource ( ) : resource
return resource

rotate() public method

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

saturation() public method

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

save() public method

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

scale() public method

Scale the image object
public scale ( float | string $scl ) : Gd
$scl float | string
return Gd

setBlur() public method

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

setColor() protected method

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

setCompression() public method

Alias to setQuality()
public setCompression ( mixed $comp = null ) : Imagick
$comp mixed
return Imagick

setFilter() public method

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

setFormats() public method

This method doesn't do anything
public setFormats ( ) : Gd
return Gd

setOpacity() public method

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

setOverlay() public method

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

setQuality() public method

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

sharpen() public method

Method to sharpen the image.
public sharpen ( integer $amount ) : Gd
$amount integer
return Gd

skew() public method

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
return Gd

swirl() public method

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

text() public method

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
return Gd

wave() public method

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

Property Details

$allowed protected_oe property

Array of allowed file types.
protected array $allowed
return array

$opacity protected_oe property

Image color opacity
protected int $opacity
return integer