PHP Class Pop\Image\Imagick

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

Protected Properties

Property Type Description
$allowed array Array of allowed file types.
$blur integer Image blur
$compression integer | string Image compression
$filter integer Image filter
$opacity float Image color opacity
$overlay integer Image overlay

Public Methods

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

Protected Methods

Method Description
getInfo ( ) : void Get Imagick Info.
setColor ( Pop\Color\Space\ColorInterface $color = null ) : mixed Set and return a color identifier.
setImageInfo ( ) : void Set the image info

Method Details

__construct() public method

Instantiate an Imagick file object based on either a pre-existing image file on disk, or a new image file. As of July 28th, 2011, stable testing was successful with the following versions of the required software: ImageMagick 6.5.* Ghostscript 8.70 or 8.71 Imagick PHP Extension 3.0.1 Any variation in the versions of the required software may contribute to the Pop\Image\Imagick component not functioning properly.
public __construct ( string $img, integer | string $w = null, integer | string $h = null, Pop\Color\Space\ColorInterface $color = null, array $types = null ) : Imagick
$img string
$w integer | string
$h integer | string
$color Pop\Color\Space\ColorInterface
$types array
return Imagick

__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 $radius, integer $sigma, integer $angle, integer $type = Imagick::BLUR ) : Imagick
$radius integer
$sigma integer
$angle integer
$type integer
return Imagick

border() public method

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

brightness() public method

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

colorTotal() public method

Return the number of colors in the palette of indexed 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 ) : Imagick
$color Pop\Color\Space\ColorInterface
return Imagick

contrast() public method

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

convert() public method

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

crop() public method

Crop the image object to a image
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 ) : Imagick
$px integer | string
$x integer | string
$y integer | string
return Imagick

desaturate() public method

Method to desaturate of the image.
public desaturate ( ) : Imagick
return Imagick

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

Apply a diffusion effect to the image
public diffuse ( integer $radius ) : Imagick
$radius integer
return Imagick

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 ) : Imagick
$x integer
$y integer
$start integer
$end integer
$w integer
$h integer
return Imagick

drawCircle() public method

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

drawEllipse() public method

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

drawLine() public method

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

drawPolygon() public method

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

drawRectangle() public method

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

drawSquare() public method

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

flatten() public method

Flatten the image layers
public flatten ( ) : Imagick
return Imagick

flip() public method

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

flop() public method

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

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\Imagick::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 Imagick 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

Method to adjust the HSB of the image altogether.
public hsb ( integer $h, integer $s, integer $b ) : Imagick
$h integer
$s integer
$b integer
return Imagick

hue() public method

Method to adjust the hue of the image.
public hue ( integer $h ) : Imagick
$h integer
return Imagick

invert() public method

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

isInstalled() public static method

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

level() public method

Method to adjust the levels of the image using a 0 - 255 range.
public level ( integer $black, float $gamma, integer $white ) : Imagick
$black integer
$gamma float
$white integer
return Imagick

noise() public method

Apply a noise effect to the image
public noise ( integer $type = Imagick::NOISE_MULTIPLICATIVEGAUSSIAN ) : Imagick
$type integer
return Imagick

output() public method

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

overlay() public method

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

paint() public method

Apply an oil paint effect to the image using the pixel radius threshold
public paint ( integer $radius ) : Imagick
$radius integer
return Imagick

pencil() public method

Apply a pencil/sketch effect to the image
public pencil ( integer $radius, integer $sigma, integer $angle ) : Imagick
$radius integer
$sigma integer
$angle integer
return Imagick

pixelate() public method

Apply a mosiac pixelate effect to the image
public pixelate ( integer $w, integer $h = null ) : Imagick
$w integer
$h integer
return Imagick

posterize() public method

Apply a posterize effect to the image
public posterize ( integer $levels, boolean $dither = false ) : Imagick
$levels integer
$dither boolean
return Imagick

resize() public method

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

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 ( ) : Imagick
return Imagick

rotate() public method

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

saturation() public method

Method to adjust the saturation of the image.
public saturation ( integer $s ) : Imagick
$s integer
return Imagick

save() public method

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

scale() public method

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

setBlur() public method

Set the image blur.
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

Set the image compression quality with an Imagick compression constant
public setCompression ( integer $comp = null ) : Imagick
$comp integer
return Imagick

setFilter() public method

Set the image filter.
public setFilter ( integer | string $filter = null ) : Imagick
$filter integer | string
return Imagick

setFormats() public method

Set the current object formats to include the supported formats of Imagick.
public setFormats ( ) : Imagick
return Imagick

setImageInfo() protected method

Set the image info
protected setImageInfo ( ) : void
return void

setOpacity() public method

Set the opacity.
public setOpacity ( float $opac ) : Imagick
$opac float
return Imagick

setOverlay() public method

Set the image overlay.
public setOverlay ( integer | string $ovr = null ) : Imagick
$ovr integer | string
return Imagick

setQuality() public method

Set the image quality.
public setQuality ( integer $q = null ) : Imagick
$q integer
return Imagick

sharpen() public method

Method to sharpen the image.
public sharpen ( integer $radius, integer $sigma ) : Imagick
$radius integer
$sigma integer
return Imagick

skew() public method

Apply a skew effect to the image
public skew ( Pop\Color\Space\ColorInterface $color, integer $x, integer $y ) : Imagick
$color Pop\Color\Space\ColorInterface
$x integer
$y integer
return Imagick

swirl() public method

Apply a swirl effect to the image
public swirl ( integer $degrees ) : Imagick
$degrees integer
return Imagick

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 ) : Imagick
$str string
$size integer | string
$x integer | string
$y integer | string
$font string
$rotate integer | string
$stroke boolean
return Imagick

wave() public method

Apply a wave effect to the image
public wave ( integer $amp, integer $length ) : Imagick
$amp integer
$length integer
return Imagick

Property Details

$allowed protected property

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

$blur protected property

Image blur
protected int $blur
return integer

$compression protected property

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

$filter protected property

Image filter
protected int $filter
return integer

$opacity protected property

Image color opacity
protected float $opacity
return float

$overlay protected property

Image overlay
protected int $overlay
return integer