Rundiz\Image

ImageInterface
in

Interface for image manipulation drivers

Tags
since
3.0

Table of Contents

Methods

clear()  : bool
Clear and reset processed results to make it ready for new process while keep the original source.
crop()  : bool
Crop the image.
getImageSize()  : array<string|int, mixed>
Get source image size
resize()  : bool
Resize the image.
resizeNoRatio()  : bool
Resize the image by ignoring aspect ratio.
rotate()  : bool
Rotate the image.
save()  : bool
Save the image to file.
show()  : mixed
Show the image.
watermarkImage()  : bool
Set the watermark image.
watermarkText()  : bool
Set the watermark text.

Methods

clear()

Clear and reset processed results to make it ready for new process while keep the original source.

public clear() : bool
Return values
bool

Return true on successfully cleared.

crop()

Crop the image.

public crop(int $width, int $height[, mixed $start_x = '0' ][, mixed $start_y = '0' ][, string $fill = 'transparent' ]) : bool
Parameters
$width : int

Image width of cropping image. Size in pixels.

$height : int

Image height of cropping image. Size in pixels.

$start_x : mixed = '0'

Position to begin in x axis. The value is integer or 'center' for automatically calculate center.

$start_y : mixed = '0'

Position to begin in y axis. The value is integer or 'middle' for automatically calculate middle.

$fill : string = 'transparent'

Color of background that will be filled in case that image has transparent in it. The value is transparent, white, black (for gif, png, webp).

Return values
bool

Return true on success, false on failed. Call to status_msg property to see the details on failure.

getImageSize()

Get source image size

public getImageSize() : array<string|int, mixed>
Return values
array<string|int, mixed>

Return array of image size with 'width' and 'height' in array key.

resize()

Resize the image.

public resize(int $width, int $height) : bool
Parameters
$width : int

Image width that image will be resize to.

$height : int

Image height that image will be resize to.

Return values
bool

Return true on success, false on failed. Call to status_msg property to see the details on failure.

resizeNoRatio()

Resize the image by ignoring aspect ratio.

public resizeNoRatio(int $width, int $height) : bool
Parameters
$width : int

Image width that image will be resize to.

$height : int

Image height that image will be resize to.

Return values
bool

Return true on success, false on failed. Call to status_msg property to see the details on failure.

rotate()

Rotate the image.

public rotate([int|string $degree = 90 ]) : bool
Parameters
$degree : int|string = 90

Degree of rotation (0, 90, 180, 270). For php >= 5.5, you can use 'hor', 'vrt', 'horvrt' as degree to flip the image.

Return values
bool

Return true on success, false on failed. Call to status_msg property to see the details on failure.

save()

Save the image to file.

public save(string $file_name) : bool
Parameters
$file_name : string

Path to save image to. Please including file extension.

Return values
bool

Return true on success, false on failed. Call to status_msg property to see the details on failure.

show()

Show the image.

public show([string $file_ext = '' ]) : mixed
Parameters
$file_ext : string = ''

The file extension that this image will be display as.

Return values
mixed

Show image content, return false on failed. Call to status_msg property to see the details on failure.

watermarkImage()

Set the watermark image.

public watermarkImage(string $wm_img_path[, int|string $wm_img_start_x = 0 ][, int|string $wm_img_start_y = 0 ][, array<string|int, mixed> $options = [] ]) : bool
Parameters
$wm_img_path : string

Full path of watermark image file

$wm_img_start_x : int|string = 0

Position to begin in x axis. The value is integer or 'left', 'center', 'right'.

$wm_img_start_y : int|string = 0

Position to begin in y axis. The value is integer or 'top', 'middle', 'bottom'.

$options : array<string|int, mixed> = []

The watermark options. (Since v3.1.3)
padding (int) Padding around watermark object. Use with left, right, bottom, top but not middle, center. See \Rundiz\Image\Traits\CalculationTrait::calculateWatermarkImageStartXY().
opacity (int) The image opacity value from 0 (full transparent) to 100 (no transparent).

Return values
bool

Return true on success, false on failure. Call to status_msg property to see the details on failure.

watermarkText()

Set the watermark text.

public watermarkText(string $wm_txt_text, string $wm_txt_font_path[, int|string $wm_txt_start_x = 0 ][, int|string $wm_txt_start_y = 0 ][, int $wm_txt_font_size = 10 ][, string $wm_txt_font_color = 'white' ][, int $wm_txt_font_alpha = 60 ][, array<string|int, mixed> $options = [] ]) : bool
Parameters
$wm_txt_text : string

Watermark text

$wm_txt_font_path : string

'True Type Font' path

$wm_txt_start_x : int|string = 0

Position to begin in x axis. The value is integer or 'left', 'center', 'right'.

$wm_txt_start_y : int|string = 0

Position to begin in x axis. The value is integer or 'top', 'middle', 'bottom'.

$wm_txt_font_size : int = 10

Font size

$wm_txt_font_color : string = 'white'

Font color. ('black', 'white', 'red', 'green', 'blue', 'yellow', 'cyan', 'magenta')

$wm_txt_font_alpha : int = 60

Text transparency value from 0 (no transparent) to 127 (full transparent).

$options : array<string|int, mixed> = []

The watermark text options. (Since v.3.1.0)
fillBackground (bool) Set to true to fill background color for text bounding box. Default is false to use transparent.
backgroundColor (string) The background color to fill for text bounding box. Available values are 'black', 'white', 'red', 'green', 'blue', 'yellow', 'cyan', 'magenta', 'debug'.
backgroundAlpha (int) The background transparency value from 0 (no transparent) to 127 (full transparent). Default is 70. padding (int) (Since v3.1.3) Padding around watermark text. Use with left, right, bottom, top but not middle, center.

Tags
since
3.2.0

New option backgroundAlpha. Removed transwhitetext from wm_txt_font_color argument but allow as fallback only.

Return values
bool

Return true on success, false on failed. Call to status_msg property to see the details on failure.


        
On this page

Search results