\ImageManagerCore

This class includes functions for image manipulation

Summary

Methods
Properties
Constants
thumbnail()
checkImageMemoryLimit()
resize()
isRealImage()
isCorrectImageFileExt()
validateUpload()
validateIconUpload()
cut()
create()
createWhiteImage()
write()
getMimeTypeByExtension()
No public properties found
ERROR_FILE_NOT_EXIST
ERROR_FILE_WIDTH
ERROR_MEMORY_LIMIT
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Constants

ERROR_FILE_NOT_EXIST

ERROR_FILE_NOT_EXIST

ERROR_FILE_WIDTH

ERROR_FILE_WIDTH

ERROR_MEMORY_LIMIT

ERROR_MEMORY_LIMIT

Methods

thumbnail()

thumbnail(string  $image, string  $cache_image, integer  $size, string  $image_type = 'jpg', boolean  $disable_cache = true, boolean  $regenerate = false) : string

Generate a cached thumbnail for object lists (eg. carrier, order statuses.

..etc)

Parameters

string $image

Real image filename

string $cache_image

Cached filename

integer $size

Desired size

string $image_type

Image type

boolean $disable_cache

When turned on a timestamp will be added to the image URI to disable the HTTP cache

boolean $regenerate

When turned on and the file already exist, the file will be regenerated

Returns

string

checkImageMemoryLimit()

checkImageMemoryLimit(  $image) : boolean

Check if memory limit is too long or not

Parameters

$image

Returns

boolean

resize()

resize(string  $src_file, string  $dst_file, integer  $dst_width = null, integer  $dst_height = null, string  $file_type = 'jpg',   $force_type = false,   $error) : boolean

Resize, cut and optimize image

Parameters

string $src_file

Image object from $_FILE

string $dst_file

Destination filename

integer $dst_width

Desired width (optional)

integer $dst_height

Desired height (optional)

string $file_type
$force_type
$error

Returns

boolean —

Operation result

isRealImage()

isRealImage(string  $filename, string  $file_mime_type = null, array  $mime_type_list = null) : boolean

Check if file is a real image

Parameters

string $filename

File path to check

string $file_mime_type

File known mime type (generally from $_FILES)

array $mime_type_list

Allowed MIME types

Returns

boolean

isCorrectImageFileExt()

isCorrectImageFileExt(  $filename,   $authorized_extensions = null) : boolean

Check if image file extension is correct

Parameters

$filename

real filename

$authorized_extensions

Returns

boolean —

true if it's correct

validateUpload()

validateUpload(array  $file, integer  $max_file_size,   $types = null) : boolean|string

Validate image upload (check image type and weight)

Parameters

array $file

Upload $_FILE value

integer $max_file_size

Maximum upload size

$types

Returns

boolean|string —

Return false if no error encountered

validateIconUpload()

validateIconUpload(array  $file, integer  $max_file_size) : boolean|string

Validate icon upload

Parameters

array $file

Upload $_FILE value

integer $max_file_size

Maximum upload size

Returns

boolean|string —

Return false if no error encountered

cut()

cut(array  $src_file, string  $dst_file, integer  $dst_width = null, integer  $dst_height = null, string  $file_type = 'jpg', integer  $dst_x, integer  $dst_y) : boolean

Cut image

Parameters

array $src_file

Origin filename

string $dst_file

Destination filename

integer $dst_width

Desired width

integer $dst_height

Desired height

string $file_type
integer $dst_x
integer $dst_y

Returns

boolean —

Operation result

create()

create(string  $type, string  $filename) : resource

Create an image with GD extension from a given type

Parameters

string $type
string $filename

Returns

resource

createWhiteImage()

createWhiteImage(integer  $width, integer  $height) : resource

Create an empty image with white background

Parameters

integer $width
integer $height

Returns

resource

write()

write(string  $type, resource  $resource, string  $filename) : boolean

Generate and write image

Parameters

string $type
resource $resource
string $filename

Returns

boolean

getMimeTypeByExtension()

getMimeTypeByExtension(string  $file_name) : string

Return the mime type by the file extension

Parameters

string $file_name

Returns

string