Methods

__construct()

__construct($config) 

Parameters

$config

Initialize by loading config

_init() : void

Adds a border to the image.

border(integer $size, string $color) : \Fuel\Core\Image_Driver

Parameters

$size

integer

The side of the border, in pixels.

$color

string

A hexadecimal color.

Returns

Accepts configuration in either an array (as $index) or a pairing using $index and $value

config(string $index, mixed $value) : \Fuel\Core\Image_Driver

Parameters

$index

string

The index to be set, or an array of configuration options.

$value

mixed

The value to be set if $index is not an array.

Returns

Crops the image using coordinates or percentages.

crop(integer $x1, integer $y1, integer $x2, integer $y2) : \Fuel\Core\Image_Driver

Positive whole numbers or percentages are coordinates from the top left.

Negative whole numbers or percentages are coordinates from the bottom right.

Parameters

$x1

integer

X-Coordinate for first set.

$y1

integer

Y-Coordinate for first set.

$x2

integer

X-Coordinate for second set.

$y2

integer

Y-Coordinate for second set.

Returns

crop_resize()

crop_resize($width, $height) 

Parameters

$width

$height

Get the file extension (type) worked out on construct

extension() : string

Returns

stringFile extension

Creates a vertical / horizontal or both mirror image.

flip(mixed $direction) : \Fuel\Core\Image_Driver

Parameters

$direction

mixed

'vertical', 'horizontal', 'both'

Returns

Turns the image into a grayscale version

grayscale() : \Fuel\Core\Image_Driver

Loads the image and checks if its compatible.

load(string $filename, string $return_data, mixed $force_extension) : \Fuel\Core\Image_Driver

Parameters

$filename

string

The file to load

$return_data

string

Decides if it should return the images data, or just "$this".

$force_extension

mixed

Decides if it should force the extension with this (or false)

Returns

Masks the image using the alpha channel of the image input.

mask(string $maskimage) : \Fuel\Core\Image_Driver

Parameters

$maskimage

string

The location of the image to use as the mask

Returns

Outputs the file directly to the user.

output(string $filetype) : array

Parameters

$filetype

string

The extension type to use. Ex: png, jpg, gif

Exceptions

\FuelException

Returns

array

Executes the presets set in the config.

preset(string $name) : \Fuel\Core\Image_Driver

Additional parameters replace the $1, $2, ect.

Parameters

$name

string

The name of the preset.

Returns

Reloads the image.

reload() : \Fuel\Core\Image_Driver

Resize the image.

resize(integer $width, integer $height, boolean $keepar, boolean $pad) : \Fuel\Core\Image_Driver

If the width or height is null, it will resize retaining the original aspect ratio.

Parameters

$width

integer

The new width of the image.

$height

integer

The new height of the image.

$keepar

boolean

If false, allows stretching of the image.

$pad

boolean

Adds padding to the image when resizing.

Returns

Rotates the image

rotate(integer $degrees) : \Fuel\Core\Image_Driver

Parameters

$degrees

integer

The degrees to rotate, negatives integers allowed.

Returns

Adds rounded corners to the image.

rounded(integer $radius, integer $sides, integer $antialias) : \Fuel\Core\Image_Driver

Parameters

$radius

integer

$sides

integer

Accepts any combination of "tl tr bl br" separated by spaces, or null for all sides

$antialias

integer

Sets the anti-alias range.

Returns

Runs all queued actions on the loaded image.

run_queue(boolean $clear) 

Parameters

$clear

boolean

Decides if the queue should be cleared once completed.

Saves the image, and optionally attempts to set permissions

save(string $filename, string $permissions) : array

Parameters

$filename

string

The location where to save the image.

$permissions

string

Allows unix style permissions

Returns

array

Saves the file in the original location, adding the append and prepend to the filename.

save_pa(string $append, string $prepend, string $extension, integer $permissions) : \Fuel\Core\Image_Driver

Parameters

$append

string

The string to append to the filename

$prepend

string

The string to prepend to the filename

$extension

string

The extension to save the image as, null defaults to the loaded images extension.

$permissions

integer

The permissions to attempt to set on the file.

Returns

Returns sizes for the currently loaded image, or the image given in the $filename.

sizes(string $filename) : object

Parameters

$filename

string

The location of the file to get sizes for.

Returns

objectAn object containing width and height variables.

Adds a watermark to the image.

watermark(string $filename, string $position, integer $padding) : \Fuel\Core\Image_Driver

Parameters

$filename

string

The filename of the watermark file to use.

$position

string

The position of the watermark, ex: "bottom right", "center center", "top left"

$padding

integer

The amount of padding (in pixels) from the position.

Returns

Executes the border event when the queue is ran.

_border(integer $size, string $color) : array

Formats the border method input for use with driver specific methods

Parameters

$size

integer

The side of the border, in pixels.

$color

string

A hexadecimal color.

Returns

arrayAn array of variables for the specific driver.

Executes the crop event when the queue is ran.

_crop(integer $x1, integer $y1, integer $x2, integer $y2) : array

Formats the crop method input for use with driver specific methods

Parameters

$x1

integer

X-Coordinate for first set.

$y1

integer

Y-Coordinate for first set.

$x2

integer

X-Coordinate for second set.

$y2

integer

Y-Coordinate for second set.

Returns

arrayAn array of variables for the specific driver.

_crop_resize()

_crop_resize($width, $height) 

Parameters

$width

$height

Executes the grayscale event when the queue is ran.

_grayscale() 

Executes the mask event when the queue is ran.

_mask(string $maskimage) : array

Formats the mask method input for use with driver specific methods

Parameters

$maskimage

string

The location of the image to use as the mask

Returns

arrayAn array of variables for the specific driver.

Executes the resize event when the queue is ran.

_resize(integer $width, integer $height, boolean $keepar, boolean $pad) : array

Formats the resize method input for use with driver specific methods.

Parameters

$width

integer

The new width of the image.

$height

integer

The new height of the image.

$keepar

boolean

If false, allows stretching of the image.

$pad

boolean

Adds padding to the image when resizing.

Returns

arrayAn array of variables for the specific driver.

Executes the rotate event when the queue is ran.

_rotate(integer $degrees) : array

Formats the rotate method input for use with driver specific methods

Parameters

$degrees

integer

The degrees to rotate, negatives integers allowed.

Returns

arrayAn array of variables for the specific driver.

Executes the rounded event when the queue is ran.

_rounded(integer $radius, integer $sides, integer $antialias) : array

Formats the rounded method input for use with driver specific methods

Parameters

$radius

integer

$sides

integer

Accepts any combination of "tl tr bl br" separated by spaces, or null for all sides

$antialias

integer

Sets the anti-alias range.

Returns

arrayAn array of variables for the specific driver.

Executes the watermark event when the queue is ran.

_watermark(string $filename, string $position, integer $padding) : array

Formats the watermark method input for use with driver specific methods

Parameters

$filename

string

The filename of the watermark file to use.

$position

string

The position of the watermark, ex: "bottom right", "center center", "top left"

$padding

integer

The amount of padding (in pixels) from the position.

Returns

arrayAn array of variables for the specific driver.

Adds a background to the image using the 'bgcolor' config option.

add_background() 

Checks if the extension is accepted by this library, and if its valid sets the $this->image_extension variable.

check_extension(string $filename, boolean $writevar, mixed $force_extension) : boolean

Parameters

$filename

string

$writevar

boolean

Decides if the extension should be written to $this->image_extension

$force_extension

mixed

Decides if the extension should be overridden with this (or false)

Returns

boolean

Converts percentages, negatives, and other values to absolute integers.

convert_number(string $input, boolean $x) : integer

Parameters

$input

string

$x

boolean

Determines if the number relates to the x-axis or y-axis.

Returns

integerThe converted number, usable with the image being edited.

Creates a new color usable by all drivers.

create_hex_color(string $hex) : array

Parameters

$hex

string

The hex code of the color

Returns

arrayrgba representation of the hex and alpha values.

Used for debugging image output.

debug() 

Queues a function to run at a later time.

queue(string $function) 

Parameters

$function

string

The name of the function to be ran, without the leading _

 Properties

 

$accepted_extensions

$accepted_extensions 

 

$config

$config 

 

$image_directory

$image_directory 

 

$image_extension

$image_extension 

 

$image_filename

$image_filename 

 

$image_fullpath

$image_fullpath 

 

$new_extension

$new_extension 

 

$queued_actions

$queued_actions