PVImage

Extends \PVStaticObject

PVImage is a class for handling the processing and format of all image files.

PVImage has various functions built into it such as adding watermarks, resizing, cropping and more. By default, the class will use Imagick but can be set to use other image processing tools.

package

media

Methods

Uses the magic method __call and executes a closure/anonymous function that has been added to the classes $_methods using the addMethod() method.

__callStatic(string $method, mixed $args = array()) : mixed
inherited static
access

public

Arguments

$method

string

The key/name assigned to the method when added

$args

mixed

Arguements to pass to the annoymous function. The function is called using call_user_func_array.

Response

mixed

$value The value returned is the value the stored function returns

Apply a fitler if filter is set.

_applyFilter(string $class, string $method, mixed $data, array $options = array()) : mixed
inherited static
access

protected

Arguments

$class

string

The name of the class the filter is in

$method

string

The method the filter is in

$data

mixed

The data that is being passed to the filter

$options

array

options to be passed to the filter. Passed options we be passed to the function. -'default_return' mixed: If no filter is return, the data passed in by default will be return. Can be overriden -'event' string: An event to associate with the filter. Default is null

Response

mixed

$data The data the function returns

Calls an adapter for this class. The easiest way of implementing an adapter is by placing the adapter at the top of the function that it is being called in. An infinite amout of parameters can be passed to the adapter BUT the parameters should be the same as the parents.

_callAdapter(string $class, string $method) : mixed
inherited static
access

protected

Arguments

$class

string

The name of the class the adapter is in

$method

string

THe name of the method the class is being called from.

Response

mixed

$value A value that the adapter returns

Checks if an adapter is set for the function.

_hasAdapter( $class, string $method) : \boolea
inherited static
access

protected

Arguments

$class

$method

string

The associated method

Response

\boolea

$hasAdapter Returns true if it has an adapter or false if it doesn not

Checks if a filter has been set.

_hasFilter(string $class, string $method) 
inherited static

Arguments

$class

string

The class the filter is in

$method

string

The method of the class that the filter is in

Calls a methods that is an instance of an class. This method is generally faster than using user_call_func_array.

_invokeMethod(string $class, string $method, array $args) : mixed
inherited static
access

protected

Arguments

$class

string

The name of the class to be called

$method

string

The name of the method in the class to be called

$args

array

An array of arguements. Arguements have to be embedded in an array to be called.

Response

mixed

$data Data returned by the function called

Calls a methods that is a static method of a class. This method is generally faster than using user_call_func_array.

_invokeStaticMethod(string $class, string $method, array $args) : mixed
inherited static
access

protected

Arguments

$class

string

The name of the class to be called

$method

string

The name of the method in the class to be called

$args

array

An array of arguements. Arguements have to be embedded in an array to be called.

Response

mixed

$data Data returned by the function called

Write out the contents of adapters used to a log

_logAdapter(array $data) : void
inherited static
access

private

Arguments

$data

array

The data in the adapter

Write out the contents of a filter used to a log

_logFilter(array $data) : void
inherited static
access

private

Arguments

$data

array

The data in the filter

Write out the contents of an observer to a log.

_logObserver(array $data) : void
inherited static
access

private

Arguments

$data

array

The data in the observer

Calls any functions that have been added to the observer if the event is present in the observers array.

_notify(string $event) : void
inherited static
access

protected

Arguments

$event

string

The name of the even that occured that will trigger notifies

Breaks down the data to be logged from an adapter, filter or observer.

_prepareLogData(array $data) : string
inherited static
access

private

Arguments

$data

array

Response

string

$message JSON encode message of information about the data

Adapters allows a method to be completely overwritten by calling a different class with the same method name. Adapters can also be used with closures. The adapter uses a strategy/adapter design pattern.

addAdapter(string $trigger_class, string $trigger_method, string $call_class, array $options = array()) : void
inherited static
access

public

todo

add ability to adapt singleton class

Arguments

$trigger_class

string

The class that contains the function the adapter will respond too

$trigger_method

string

The method called that will have the adapter to be called.

$call_class

string

The new class to be called that has the same method name

$options

array

An array of options that be called -'object' string : Assumes that default method in the class to be called is static. If called object needs to be instantiated, change to object to 'instance' and one will be created before the adapter calls the function -'call_method' string: By default the method to be called to override the current one should be the same name. But this can be ovveridden to call a different method. -'type' string: The type of method being called. Default is class_method but if the method is a closure, set the type to be 'closure' and make the $trigger_method the closure

Will add an adapter for every method in the trigger_class to another class. The method will only be adapted to another class if the method in the trigger class has an adapter. This functionality can be very similiar to DI.

addClassAdapter(mixed $trigger_class, string $call_class, array $options = array()) : void
inherited static
access

public

todo

Add ability to use singleton classes

Arguments

$trigger_class

mixed

This can either be the name of the class or an object whose methods will be adapted to another class. The class should be included or be autoloaded by this point.

$call_class

string

The call class is the classes methods that will be called in place of the methods in the trigger_class. These class does not have to be included as this point.

$options

array

Options that be used to further distinguish the behavior of the adapters added -'object' string: Determines if the object being adapted to is static or an instance.Default is static -'call_class' string: The name of the class that the methods will be adapted too. -'class' string: The name of the whose methods will be adapted to another class

Adds a filter to the class. Filters are for modifying a value within a class and should not interpet the normal flow within the method.

addFilter(string $class, string $method, string $filter_class, string $filter_method, array $options = array()) : void
inherited static
access

public

Arguments

$class

string

The name of the class the filter is going in

$method

string

The name of the method the filter is in

$filter_class

string

The class that the filter resides in.

$filter_method

string

The method in the class that the parameters will be passed too.

$options

array

Options that can be set for further modifying the filter. -'object' string: If the method being called is static, static should be inserted. If its in an instance, 'instance' should be set. Default is set to static. -'event' string: Associate this filter with an event. -'type' string: The type of function being called. Default is class_method but if the function is a closure, set the type to be 'closure' and make the $filter_method the closure

Adds a closure/anonymous function to the object that can be called.

addMethod(string $method, \function $closure) : void
inherited static
access

public

Arguments

$method

string

The key/value that will be used to call the function

$closure

\function

The anonymous function/closure to be added

Adds an observer to the class. Observer events can fired in any method to trigger a response.

addObserver(string $event, string $class, string $method, array $options = array()) : void
inherited static
access

public

Arguments

$event

string

The name of the event that will cause a certain class and method to fire

$class

string

The name of the class that contains the function that will be fired for this event

$method

string

The name of the method that will be fired when the event occurs

$options

array

Options to further the define the firing of an event -'object' string : If the method being called is static, should be set to static. Else set to instance -'class' stinrg : The name of the class to be called. Default is the class that is passed in. -'method' string: The name of the method to be called. Default is the method that is passed in. -'type' string: The type of function being called. Default is class_method but if the function is a closure, set the type to be 'closure' and make the $method the closure

Adds a data to the public collection, index will be assigned automatically. Primarily used for adding launch quanties of data to the collection

addToCollection(mixed $data) : void
inherited static
access

public

Arguments

$data

mixed

Any data type( Object, Array, int, etc) to add to the public data collection

Adds data to the public collection. The data is assigned a key/index. If the key/index is already set, new information will override the old one.

addToCollectionWithName(string $name, mixed $data) : void
inherited static
access

public

todo

check the relevance of get and set

Arguments

$name

string

The key/index to assign the value to

$data

mixed

Data to be stored in the collection

Takes an array of images and put them into an animated gif. The method accepts images as blobs/bytes, locations to a file, or an imagick object that is holding an image.

animateImage(array $data, array $options = array()) : \$mixed
static
access

public

todo

add GD support

Arguments

$data

array

The day is the array of images to be passed in. The data at each index can either be a blog/bytes, location to a file, or an imagick object with animage

$options

array

Options that control the animating of images -'converter' string: The default converter set by the init function -'write_image' boolean: Write the image out to file. Default is true. -'write_image_location' string: The location to save the image. Default is the save location set in the init -'write_image_name' string: A name to save the image as. Default is a random string. -'add_extension' boolean: Add a file extension to the write_image_name. Default is true. -'return' string: Specifiy to return an object or file location. Default is set in the init() -'format' string: The format to save the image in. Default is gif. -'image_delay' integer: The delay between the images, default is 30 -'image_width' integer: The width of the images -'image_height' integer: The height of the images

Response

\$mixed

$value The value return is set by the option. Either the location to the file is return or the object for creating the image.

Combines an array of strings together to create an image of animated text.

animateText(array $data, array $options = array()) : mixed
static
access

public

todo

add GD support

Arguments

$data

array

The array of strings. Each index in the array should be a different string

$options

array

An array of options that can determine how the string will be animated -'converter' string: The default converter set by the init function. -'write_image' boolean: Write the image out to file. Default is true. -'write_image_location' string: The location to save the image. Default is the save location set in the init -'write_image_name' string: A name to save the image as. Default is a random string. -'display_image' boolean: Determines if the image is to be displayed automatically in a header. Default is false. -'add_extension' boolean: Add a file extension to the write_image_name. Default is true. -'return' string: Specifiy to return an object or file location. Default is set in the init() -'format' string: The format to save the image in. Default is gif. -'image_delay' integer: The delay between the images, default is 30 -'image_width' integer: The width of the images -'image_height' integer: The height of the images -'font' string: The font to be used when writing text. Defaultis Helvetica -'font_size' int: The size of the font to be used. Default is 20 -'font_color' string: The color of the font. Default is black. -'font_style' int: The style of the font. Default is Imagick::Style_Normal -'fill_alpha' _double: The number between 0 and 1 on how transparent the text is. Default is 1. -'position_x' int: The starting position of the text on the x-coordinate. Default is 0. -'position_y' int: The starting position of the text on the y-coordinate. Default is 0. -'rotation' int: The number of degress to rotate the text. Default is 0. -'gravity' int: The imagick defined constant on the gravity of the text. Default is Imagick::GRAVITY_CENTER -'pixel_color' string: Serves as the background color the text will be placed on. Default is white

Response

mixed

$return The data to be return. Return is set in the options

Remove all the filters from a class.

clearFilters(string $class, string $method) : void
inherited static
access

public

Arguments

$class

string

The class the filter is in

$method

string

The method of the class that the filter is in

Removes all the observers assoicated with an event.

clearObservers(string $event) : void
inherited static
access

public

Arguments

$event

string

The event to remove all the observers from

Converts an image to another format.

convertImageFormat(mixed $image, string $format, array $options = array()) : \$mixed
static
access

public

todo

add GD support

Arguments

$image

mixed

The image can either be the location of an image on a server or a bytes of an image. If the passed variable is bytes, remember to set the option type to 'blob'

$format

string

The format to change the image into. The most common are png, gif and jpeg.

$options

array

Options that can alter the conversion process -'converter' string: The default converter set by the init function -'write_image' boolean: Write the image out to file. Default is true. -'write_image_location' string: The location to save the image. Default is the save location set in the init -'write_image_name' string: A name to save the image as. Default is a random string. -'add_extension' boolean: Add a file extension to the write_image_name. Default is true. -'return' string: Specifiy to return an object or file location. Default is set in the init() -'format' string: The format to save the image in. Default is gif.

Response

\$mixed

$value The value return is set by the option. Either the location to the file is return or the object for creating the image.

Crops the image

cropImage(string $src, string $output, double $width, double $height) : void
static
todo

redo and finish, output is never being called

Arguments

$src

string

The name and location of the file to crop

$output

string

The location to output the new file

$width

double

The width of the file

$height

double

The hieght of the file

Creates a drop shadown behind an image.

drawDropShadow(mixed $image, array $options = array()) : mixed
static
access

public

todo

add GD support

Arguments

$image

mixed

The value passed in can either be the location on a file system or the images in bytes. If the image is bytes, the options 'type' = blob my be set.

$options

array

Options that can be used for further configuring the dropshadow -'converter' string: The default converter set by the init function. -'write_image' boolean: Write the image out to file. Default is true. -'write_image_location' string: The location to save the image. Default is the save location set in the init -'write_image_name' string: A name to save the image as. Default is a random string. -'display_image' boolean: Determines if the image is to be displayed automatically in a header. Default is false. -'add_extension' boolean: Add a file extension to the write_image_name. Default is true. -'return' string: Specifiy to return an object or file location. Default is set in the init() -'format' string: The format to save the image in. Default is png. -'offest_x' int: The offset on the x_coordinate when placing the drop shadow. Default is 0 -'offeset_y' int: The offset on the y_coordinate when placing the drop shadow. Default is 0. -'radius_x' int: Default is width/2 -'radius_y' int: Default height /2

Response

mixed

$return The data to be returned. The type of data that is returned is set in the options

Draws an ellipse shape based on the passed values.

drawEllipse(double $width, double $height, string $color, array $options = array()) : mixed
static
access

public

todo

add GD support

Arguments

$width

double

The width of the ellipse

$height

double

The height of the ellipse

$color

string

The color of the ellipse

$options

array

Options that can be used for further configuring the ellipse -'converter' string: The default converter set by the init function. -'write_image' boolean: Write the image out to file. Default is true. -'write_image_location' string: The location to save the image. Default is the save location set in the init -'write_image_name' string: A name to save the image as. Default is a random string. -'display_image' boolean: Determines if the image is to be displayed automatically in a header. Default is false. -'add_extension' boolean: Add a file extension to the write_image_name. Default is true. -'return' string: Specifiy to return an object or file location. Default is set in the init() -'format' string: The format to save the image in. Default is png. -'offest_x' int: The offset on the x_coordinate when drawing the ellipse. Default is the width/2 -'offeset_y' int: The offset on the y_coordinate when drawign the ellipse. Default is height/2 -'radius_x' int: Default is width/2 -'radius_y' int: Default height /2

Response

mixed

$return The data to be returned. The type of data that is returned is set in the options

Creates an rectangular image.

drawImage(integer $width, integer $height, string $color, array $options = array()) : mixed
static
access

public

todo

add GD support

Arguments

$width

integer

The width of the image

$height

integer

The height of the image

$color

string

The color of the image

$options

array

Options that can be used to configure the drawing of the shape -'converter' string: The default converter set by the init function. -'write_image' boolean: Write the image out to file. Default is true. -'write_image_location' string: The location to save the image. Default is the save location set in the init -'write_image_name' string: A name to save the image as. Default is a random string. -'display_image' boolean: Determines if the image is to be displayed automatically in a header. Default is false. -'add_extension' boolean: Add a file extension to the write_image_name. Default is true. -'return' string: Specifiy to return an object or file location. Default is set in the init() -'format' string: The format to save the image in. Default is png.

Response

mixed

$return The data to be returned. The type of data that is returned is set in the options

Retrieves a value that is in the public data collection or was pass through by the set method.

get(string $index) : mixed
inherited static
access

public

Arguments

$index

string

The index to retrieve a value from

Response

mixed

$data The data that was stored at that index

Returns the height image of the image. By default, Imagick will be used if it installed, otherwise the GD libraries will be used.

getImageHeight(string $image, array $options = array()) : integer
static
access

public

todo

add GD support

Arguments

$image

string

The location of the image

$options

array

Response

integer

$height The height of the image

Returns the width image of the image. By default, Imagick will be used if it installed, otherwise the GD libraries will be used.

getImageWidth(string $image, array $options = array()) : integer
static
access

public

todo

implement with GD functions

Arguments

$image

string

The location of the image

$options

array

Response

integer

$width The width of the image

Returns the instance of a class. Used for implementing the singleton design pattern. Class will only be instantiated once.

getInstance() : object
inherited static
access

public

Response

object

$instance Returns the instance of a class.

Returns the iterator for iterating through the values stored in the classes collection.

getIterator() : \PVIterator
inherited static

Response

\PVIterator

$iterator The classes collection in an iteratable form

access public

Initalize the PVImage class with default variables for image conversion

init( $config = array()) : void
static
access

public

Arguments

$config

Removes an adapter.

removeAdapter( $class, string $method) : void
inherited static
access

public

Arguments

$class

$method

string

The associated method

Removes an adapter for an entire class.

removeClassAdapter( $class) : void
inherited static
access

public

Arguments

$class

Resizes the image use GD, not Imagick

resizeImageGD(string $name, string $filename, double $new_w = 150, double $new_h = 150) : void
static
todo

revisit implementation

Arguments

$name

string

The location and name of the file

$filename

string

The name an location of the new file

$new_w

double

The new width to resize too

$new_h

double

The new height to resize too

Scale an image to a new size based on the passed width and height.

scaleImage(mixed $image, double $width, double $height, array $options = array()) : \$mixed
static
access

public

todo

add GD support

Arguments

$image

mixed

Either pass the location of the file on a server or the image as bytes. If the image is passed as bytes, set the options type to 'blob'

$width

double

The width to scale the image too

$height

double

The height to scale the image too.

$options

array

Options that control the animating of images -'converter' string: The default converter set by the init function -'write_image' boolean: Write the image out to file. Default is true. -'write_image_location' string: The location to save the image. Default is the save location set in the init -'write_image_name' string: A name to save the image as. Default is a random string. -'add_extension' boolean: Add a file extension to the write_image_name. Default is true. -'return' string: Specifiy to return an object or file location. Default is set in the init() -'format' string: The format to save the image in. Default is gif. -'bestfit' boolean: Scales image to the best fit. Default is false.

Response

\$mixed

$value The value return is set by the option. Either the location to the file is return or the object for creating the image.

Adds a value to the classes Collection. By default the collection is stored in the public collection. The stored instance can be retrieved later by called in it's key value.

set(string $index, mixed $value) : void
inherited static
access

public

Arguments

$index

string

The key or index to store the value at

$value

mixed

A mixed value that can be anytype

Turn on/off the ability to trace an adapter.Turning on will log an adapter using PVLog when adapter is executed.

setAdapterTrace(boolean $trace = false) : void
inherited static
access

public

Arguments

$trace

boolean

Default is false. If set to true, will trace adatper.

Turn on/off the ability to trace an filter.Turning on will log a filter using PVLog when filter is executed.

setFilterTrace(boolean $trace = false) : void
inherited static
access

public

Arguments

$trace

boolean

Default is false. If set to true, will trace filter.

Turn on/off the ability to trace an observer.Turning on will log an observer using PVLog when the observer is executed.

setObserverTrace(boolean $trace = false) : void
inherited static
access

public

Arguments

$trace

boolean

Default is false. If set to true, will trace observer.

Converts a string of text into an image

textToImage(array $string, array $options) : mixed
static
access

public

todo

add GD support

Arguments

$string

array

The string to be converted into an image

$options

array

An array of options that can determine how the string will be animated -'converter' string: The default converter set by the init function. -'write_image' boolean: Write the image out to file. Default is true. -'write_image_location' string: The location to save the image. Default is the save location set in the init -'write_image_name' string: A name to save the image as. Default is a random string. -'display_image' boolean: Determines if the image is to be displayed automatically in a header. Default is false. -'add_extension' boolean: Add a file extension to the write_image_name. Default is true. -'return' string: Specifiy to return an object or file location. Default is set in the init() -'format' string: The format to save the image in. Default is gif. -'image_delay' integer: The delay between the images, default is 30 -'image_width' integer: The width of the images -'image_height' integer: The height of the images -'font' string: The font to be used when writing text. Defaultis Helvetica -'font_size' int: The size of the font to be used. Default is 20 -'font_color' string: The color of the font. Default is black. -'font_style' int: The style of the font. Default is Imagick::Style_Normal -'fill_alpha' _double: The number between 0 and 1 on how transparent the text is. Default is 1. -'position_x' int: The starting position of the text on the x-coordinate. Default is 0. -'position_y' int: The starting position of the text on the y-coordinate. Default is 0. -'rotation' int: The number of degress to rotate the text. Default is 0. -'gravity' int: The imagick defined constant on the gravity of the text. Default is Imagick::GRAVITY_CENTER -'pixel_color' string: Serves as the background color the text will be placed on. Default is white

Response

mixed

$return The data to be returned. The type of data that is returned is set in the options

Creates a watermark over an image with another image

watermarkImageWithImage(mixed $image, string $watermark, array $options = array()) : mixed
static
access

public

todo

add GD support

Arguments

$image

mixed

The value passed in can either be the location on a file system or the images in bytes. If the image is bytes, the options 'type' = blob my be set.

$watermark

string

The location of the image or base the image in as a blob

$options

array

Options that can be used for further configuring the dropshadow -'converter' string: The default converter set by the init function. -'write_image' boolean: Write the image out to file. Default is true. -'write_image_location' string: The location to save the image. Default is the save location set in the init -'write_image_name' string: A name to save the image as. Default is a random string. -'display_image' boolean: Determines if the image is to be displayed automatically in a header. Default is false. -'add_extension' boolean: Add a file extension to the write_image_name. Default is true. -'return' string: Specifiy to return an object or file location. Default is set in the init() -'format' string: The format to save the image in. Default is png. -'type' string: The format the image is in before manipulation. If a blob fo byties is being passed set type to 'blob', otherwise type will be file. -'offest_x' int: The offset on the x_coordinate when placing the drop shadow. Default is 0 -'offeset_y' int: The offset on the y_coordinate when placing the drop shadow. Default is 0.

Response

mixed

$return The data to be returned. The type of data that is returned is set in the options

Add's a watermark to an image. By default use imagick but if that is not installed, the default will be gd.

watermarkImageWithText(mixed $image, string $watermark, array $options = array()) : mixed
static
access

public

todo

add GD support

Arguments

$image

mixed

The value passed in can either be the location on a file system or the images in bytes. If the image is bytes, the options 'type' = blob my be set.

$watermark

string

The the text to add as a watermark

$options

array

Options that can be used for further configuring the dropshadow -'converter' string: The default converter set by the init function. -'write_image' boolean: Write the image out to file. Default is true. -'write_image_location' string: The location to save the image. Default is the save location set in the init -'write_image_name' string: A name to save the image as. Default is a random string. -'display_image' boolean: Determines if the image is to be displayed automatically in a header. Default is false. -'add_extension' boolean: Add a file extension to the write_image_name. Default is true. -'return' string: Specifiy to return an object or file location. Default is set in the init() -'format' string: The format to save the image in. Default is png. -'type' string: The format the image is in before manipulation. If a blob fo byties is being passed set type to 'blob', otherwise type will be file.

Response

mixed

$return The data to be returned. The type of data that is returned is set in the options

Properties

The tool used to process images, default imagic but can be GD or another class

_converter : 
static

Type(s)

Boolean to automatically an image to file, setup in the PV_IMAGE constant.

_write_image : 
static

Type(s)

If write_image is set to true, the location to write the image

_write_image_location : 
static

Type(s)

Boolean to display the image once processed. Will add image headers.

_display_image : 
static

Type(s)

For processed images, will automatically add the correct extenison to the image

_add_extension : 
static

Type(s)

For processed images, can return various types including the Imagick Object, string of bytes, or the location if written to file.

_return : 
static

Type(s)

A collection of items that belong to this class

_collection : 
inherited static

Type(s)

A collection of dynamically added methods that below to this class

_methods : 
inherited static

Type(s)

The adapters that have been added

_adapters : 
inherited static

Type(s)

Observers that have been added

_observers : 
inherited static

Type(s)

Instances for singleton that have added

_instances : 
inherited static

Type(s)

Intercepting filters that have been added

_filters : 
inherited static

Type(s)

Boolean for following and logging adapters that have been added

_traceAdapters : 
inherited static

Type(s)

Boolean for following and logging filters that have been added

_traceFilters : 
inherited static

Type(s)

Boolean for following and logging observers that have been added.

_traceObservers : 
inherited static

Type(s)