PHP class ImageFragmentator documantation page

public function ifSave($source_image, $fragment_width, $fragment_height, $fragment_name_pattern)

Method save all fragments of source image as files.

attribute $source_image

Path to source image. Attribute is required. Value must by a string.

attribute $fragment_width

Width of fragment in pixels. Attribute is required. Value must by an int.

attribute $fragment_height

Height of fragment in pixels. Attribute is required. Value must by an int.

attribute $fragment_name_pattern

Pattern of name of fragments files. In pattern can by used following signs:
[c] = counter of fragments in source image (by rows and columns),
[pc] = as [c] but padding,
[cx] = the row number in which is the fragment,
[pcx] = as [cx] but padding,
[cy] = the column number in which is the fragment,
[pcy] = as [cy] but padding.
If attribute missing, is pattern as $source_image but before the extension of the file is inserted string '.[pc]'
Attribute is implied.
Value must by a string.

example #1

$instance->ifSave("image.jpg", 50, 50, "result.[c]");
// if sizes of image.jpg are 200 x 200 px
// that names of saved files of fragments are
// result.1.jpg
// result.2.jpg
// ...
// result.16.jpg

example #2

$instance->ifSave("image.jpg", 50, 50, "result.[pc]");
// if sizes of image.jpg are 200 x 200 px
// that names of saved files of fragments are
// result.01.jpg
// result.02.jpg
// ...
// result.16.jpg

example #3

$instance->ifSave("image.jpg", 50, 50, "result.[cy]-[cx]");
// if sizes of image.jpg are 200 x 200 px
// that names of saved files of fragments are
// result.1-1.jpg
// result.1-2.jpg
// ...
// result.4-3.jpg
// result.4-4.jpg

public function ifReturn($source_image, $fragment_width, $fragment_height, $row_number, $column_number)

Method return a fragment as string with header information about mime type of image.

attribute $source_image

Path to source image. Attribute is required. Value must by a string.

attribute $fragment_width

Width of fragment in pixels. Attribute is required. Value must by an int.

attribute $fragment_height

Height of fragment in pixels. Attribute is required. Value must by an int.

attribute $row_number

The row number in which is the fragment. Attribute is required. Value must by an int.

attribute $column_number

The column number in which is the fragment. If missing this attribure (or is 0) that previous attribute $row_number countain number of fragment in image. Attribute is implied. Value must by an int.

example #1

/*
IMAGE EXAMPLE PLAN
r = row
c = column
f = fragment
     r1   r2   r3
   +----+----+----+
c1 | f1 | f2 | f3 |
   +----+----+----+
c2 | f4 | f5 | f6 |
   +----+----+----+
c3 | f7 | f8 | f9 |
   +----+----+----+
*/
$instance->ifReturn("image.jpg", 50, 50, 2, 2);
// if sizes of image.jpg are 150 x 150 px
// that return fragment f5 (see IMAGE EXAMPLE PLAN)

example #2

$instance->ifReturn("image.jpg", 50, 50, 2);
// if sizes of image.jpg are 150 x 150 px
// that return fragment f2 (see IMAGE EXAMPLE PLAN in example #1)

public function ifSetFragmentsMimeType($mime_type)

Method set a mime type of fragments.

attribute $mime_type

Mime type of fragments. Default value is 'image/jpeg'. Attribute is required. Value must by a string.

example #1

$instance->ifSetFragmentsMimeType("image/png");
$instance->ifSave("image.jpg", 50, 50, "result.[c]");
// if sizes of image.jpg are 200 x 200 px
// that names of saved files of fragments are
// result.1.png
// result.2.png
// ...
// result.16.png

example #2

$instance->ifSetFragmentsMimeType("image/gif");
$instance->ifReturn("image.jpg", 50, 50, 2);
// if sizes of image.jpg are 150 x 150 px
// that return fragment f2 with mime type "image/gif"

public function ifSetOverflow($overflow)

Method set an overflow status.

attribute $overflow

Status of overflow. If status is false that fragments are copied only from area of source image. If status is true that fragments containing an empty part (beyond the source image). Default value is false. Attribute is required. Value must by a boolean.

example #1

$instance->ifSave("image.jpg", 75, 75, "result.[c]");
// if sizes of image.jpg are 200 x 200 px
// that count of saved files is 4

example #2

$instance->ifSetOverflow(true); $instance->ifSave("image.jpg", 75, 75, "result.[c]");
// if sizes of image.jpg are 200 x 200 px
// that count of saved files is 9 (5 with blank area)

public function ifSetOverflowColor($color)

Method set a color of overflow areas.

attribute $color

Color in hexadecimal (with or without number sign #). Default value is '000000', black. Attribute is required. Value must by a string.

public function ifSetOverflowAlpha($alpha)

Method set an alpha channel of overflow areas (only if mime type of fragments is 'image/png' or 'image/gif').

attribute $alpha

Status of alpha channel. See method ifSetOverflowColor. Default value is false. Attribute is required. Value must by a boolean.

public function ifSetOverflowCut($cut)

Method set an empty parts cutting status.

attribute $cut

Status of overflow cutting. If status is false that fragments are contains an empty parts. If status is true that empty parts of fragments are cutting. See method ifSetOverflow. Default value is false. Attribute is required. Value must by a boolean.