Properties

$use_cache

$use_cache : boolean

Set whether Cache is used It is strongly recommended that you enable this. If you do, this will also allow methods to return thumbnail data and remote image data retrival should allow_url_fopen be disabled.

Type

boolean

$clear_cache

$clear_cache : boolean

Set to clear cache after thumbnail generation Useful if you want to enable features that require the cache but do not want normal images to be cached.

Type

boolean

$cache_dir

$cache_dir : string

Set the DIR of cache file. Include Trailing Slash or methods will FAIL!

Type

string

$error_mode

$error_mode : integer

Set behaviour of script when fatal error is encountered.

Set to 0 to end script execution when an error is encountered with a die() statement. Set to 1 to End script execution when an error is encountered with an image displaiyng the error Set to 2 to log error in array

Type

integer

$log_error

$log_error : boolean

Set to log error messages to file error_log in cache directory (Requires cache to be enabled!)

Type

boolean

$remote_check

$remote_check : boolean

Set to retrieve remote data on every request. Defaults to True If set to false, remote files will be cached and any changes to remote files will not be reflected, unless file cache is destroyed.

Therefore, this option requires cache to be enabled to be set to false.

Type

boolean

$remote_wrapper

$remote_wrapper : 

Type

$error_array

$error_array : array

An array of error messages

Type

array

$data_cache

$data_cache : array

An array of cache'd remote file data

Type

array

$file_ext

$file_ext : array

An array mapping PHP image format IDs to their appropriate file extensions

This also declares the image format supported.

Type

array

$thumb_quality

$thumb_quality : 

Type

$exif_rotation

$exif_rotation : 

Type

Methods

__construct()

__construct(  $quality,   $exifrotation) 

The class constructor.

Parameters

$quality
$exifrotation

is_cacheable()

is_cacheable() : boolean

Check whether it is possible to cache

Returns

boolean

set_error()

set_error(string  $msg, boolean  $is_fatal = true) : boolean

Sets an error to the error_array array. Method always returns false.

Parameters

string $msg

Error Message

boolean $is_fatal

Set to true to enable a fatal error that will terminate script

Returns

boolean

log_error()

log_error(string  $msg, boolean  $is_fatal = true) : \Pydio\Editor\Image\none

Logs an error to error log

Parameters

string $msg

Error Message

boolean $is_fatal

Set to true to enable a fatal error

Returns

\Pydio\Editor\Image\none

error()

error(boolean  $fatal_error = true) : array

Function to get the error message from the array

Parameters

boolean $fatal_error

Set to true to return fatal errors or false for warnings

Returns

array

isError()

isError() : boolean

Returns true if there is an error inside error_array

Returns

boolean

print_thumbnail()

print_thumbnail(string  $image, integer  $width, integer  $height, boolean  $return_img = false, boolean  $display_inline = true,   $target_file = false) : string

Prints out and cache the thumbnail. Returns verbose errors.

Parameters

string $image

The Relative Path to the image

integer $width

The Width of the new thumbnail

integer $height

The Height of the thumbnail

boolean $return_img

Set to true to return the string instead of outputting it. Default to false

boolean $display_inline

If set to true, heaers sent to browser will instruct it to display the image inline instead of asking the user to download. Defaults to true.

$target_file

Returns

string

hex2dec()

hex2dec(string  $hex) : array

Function to turn a HEX Based color into an array of RBG

http://sg2.php.net/hexdec User Comment by henrique at recidive dot com

Parameters

string $hex

The Color code in HEX

Returns

array

output_text()

output_text(string  $text, integer  $width, integer  $height, integer  $size, string  $font, integer  $x, integer  $y, string  $bg = "ffffff", string  $textcolor = "000000") 

Generate an image with the specified font and options. Image generated is always PNG.

MAKE SURE TO GIVE COLOUR CODES IN HEX FORM!

Parameters

string $text

The Text to output

integer $width

The width of the image

integer $height

The Width of the Image

integer $size

The Font size of the text

string $font

The Font of the text to use

integer $x

The X-co-ordinate of the lower left corner of the text

integer $y

The Y-Co-ordinate of the lower left of the text

string $bg

The Background colour of the text. Defaults to #ffffff

string $textcolor

The Colour of the text Defaults to #000000

is_remote()

is_remote(string  $address) : integer

Validates whether a Given URL is valid or whether it is a remote URL

Returns 0 if it is not remote Returns 1 if it is remote and is accessible

Parameters

string $address

URL

Returns

integer

scale_thumbnail()

scale_thumbnail(string  $image, \Pydio\Editor\Image\number  $magnitude, boolean  $return = false) : mixed

Scale the image to the magnitude specified and then calls print_thumbnail Returns the dimensions calculated on request

Parameters

string $image

The Image

\Pydio\Editor\Image\number $magnitude

The magnitude of scaling Value can be a float of integer

boolean $return

Whether to return the values or to call print_thumbnail. If set to true, will return an array or Width and Height respectively

Returns

mixed

fit_thumbnail()

fit_thumbnail(string  $image, integer  $max_width = -1, integer  $max_height = -1, integer  $behaviour = 1,   $return = false) : mixed

Calculate the best Image dimensions so that they fit within the supplied dimensions.

Returns the dimensions calculated on request

i.e. If you call this method with $width and $height of 200 and 100 and the $image provided is 500,250 A calculation will be made so that the width and height of the thumbnail does not alter the image width,height ratio

Parameters

string $image

The Image

integer $max_width

The Width. Set to -1 for no restrictions

integer $max_height

The height. Set to -1 for no restrictions

integer $behaviour

Sometimes, 2 values are obtained. Set this to 1 to return the one with the bigger pixel area or 2 to return the one with smaller pixel area.

$return

Returns

mixed

image_to_file()

image_to_file(string  $image, string  $filename, boolean  $overwrite = false) : boolean

Writes an image file according to data provided. This method is just here to save scripters some trouble.

Users have to ensure directory can be written to!

Parameters

string $image

The Image data

string $filename

The relative path to the image file to be written

boolean $overwrite

Specifies whether the file, if it exists, should be overwritten or not.

Returns

boolean

retrieve_remote_file()

retrieve_remote_file(string  $url, boolean  $skip_checks = false, boolean  $refresh = false, integer  $force_method = 2) : mixed

Attempts to retrieve a remote file data and returns it. Returns false on error.

Returns string on success, 0 on failure after repeated attempts using different methods, 1 on invalid URL, 2 on inaccessible URL, 3 on file not exist error

Parameters

string $url

URL

boolean $skip_checks

Set to skip URL validating

boolean $refresh

Set to ignore cache

integer $force_method

Force a certain method of file retrival. Set to null

Returns

mixed

retrieve_image_data()

retrieve_image_data(string  $file) : array

Retrieves image data. Workaround for allow_url_fopen if it is disabled Does not validate file existence

Parameters

string $file

Filename

Returns

array

clear_cache()

clear_cache() 

Clears Cache

fastimagecopyresampled()

fastimagecopyresampled(  $dst_image,   $src_image,   $dst_x,   $dst_y,   $src_x,   $src_y,   $dst_w,   $dst_h,   $src_w,   $src_h,   $quality = 1) 

Parameters

$dst_image
$src_image
$dst_x
$dst_y
$src_x
$src_y
$dst_w
$dst_h
$src_w
$src_h
$quality

exiforientation()

exiforientation(  $image,   $fetch) 

Parameters

$image
$fetch

rotationsupported()

rotationsupported(  $exif_orientation) 

Parameters

$exif_orientation