\cg_watermark

A class to provide a convenient way of watermarking images.

it uses preferences from the CGExtensions module admin panel.

Summary

Methods
Properties
Constants
__construct()
get_error()
set_watermark_text()
set_watermark_image()
set_alignment()
get_alignment()
set_font()
set_text_size()
set_text_angle()
set_text_color()
set_background_color()
set_translucency()
is_ready()
create_watermarked_image()
No public properties found
ALIGN_UL
ALIGN_UC
ALIGN_UR
ALIGN_ML
ALIGN_MC
ALIGN_MR
ALIGN_LL
ALIGN_LC
ALIGN_LR
ERROR_NOTREADY
ERROR_BADFILE
ERROR_BADFILETYPE
ERROR_NOFILE
ERROR_CREATEWM
ERROR_LOADIMG
ERROR_OTHER
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Constants

ALIGN_UL

ALIGN_UL

ALIGN_UC

ALIGN_UC

ALIGN_UR

ALIGN_UR

ALIGN_ML

ALIGN_ML

ALIGN_MC

ALIGN_MC

ALIGN_MR

ALIGN_MR

ALIGN_LL

ALIGN_LL

ALIGN_LC

ALIGN_LC

ALIGN_LR

ALIGN_LR

ERROR_NOTREADY

ERROR_NOTREADY

ERROR_BADFILE

ERROR_BADFILE

ERROR_BADFILETYPE

ERROR_BADFILETYPE

ERROR_NOFILE

ERROR_NOFILE

ERROR_CREATEWM

ERROR_CREATEWM

ERROR_LOADIMG

ERROR_LOADIMG

ERROR_OTHER

ERROR_OTHER

Methods

__construct()

__construct()

Construct a new cg_watermark object.

get_error()

get_error() : string

Return any error from the last watermark operation.

Returns

string

set_watermark_text()

set_watermark_text(string $text)

Set the text to use for watermarking.

This will ensure that no watermarking image is used.

Note: HTML tags cannot be used. It is unsure how newline or tab characters will be rendered.

Parameters

string $text

set_watermark_image()

set_watermark_image(string $filename)

Set the watermark image.

This will reset any watermark text.

Parameters

string $filename

set_alignment()

set_alignment(string $alignment)

Set the alignment for the watermark text or image.

Parameters

string $alignment

One of the alignment constants.

get_alignment()

get_alignment()

Get the alignment (if any) for this watermarking.

The default value is ALIGN_MC

set_font()

set_font(string $font)

Set the font for text based watermarks.

Parameters

string $font

set_text_size()

set_text_size(int $points)

Set the text size for text based watermarking.

Parameters

int $points

The point size of the text.

set_text_angle()

set_text_angle(int $angle)

Set the angle for the text in text based watermarking.

Parameters

int $angle

The angle (in degrees). Default value is 0

set_text_color()

set_text_color(int $red, int $green, int $blue)

Set the color for text based watermarking.

The default value for this setting is white (255,255,255)

Parameters

int $red

(red portion, between 0 and 255)

int $green

(green portion, between 0 and 255)

int $blue

(blue portion, between 0 and 255)

set_background_color()

set_background_color(int $red, int $green, int $blue, bool $transparent)

Set the background color for text based watermarks.

The default value is black (0,0,0) and transparent.

Parameters

int $red

The red value for the color (between 0 and 255)

int $green

The green value for the color (between 0 and 255)

int $blue

The blue value for the color (between 0 and 255)

bool $transparent

Wether the background color is to be treated as transparent.

set_translucency()

set_translucency(int $num)

Allows setting the alpha channel translucency for watermarks.

Parameters

int $num

A value between 0 and 100 where 100 is absolutely no translucency.

is_ready()

is_ready() : bool

Test wether all information is set and ready for performing watermarking on an image.

Returns

bool

create_watermarked_image()

create_watermarked_image(string $srcfile, string $destfile) : bool

Watermark an input image given the current settings, and output it into the destination location.

Parameters

string $srcfile

The input file specification. Must be an image file

string $destfile

The output file specification. Must be a writable location.

Returns

bool