# \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

File
  lib/class.cg_watermark.php
Package
  \CGExtensions
Class hierarchy
  \cg_watermark

## Tags

todo |

## Constants

### ALIGN_UL

    ALIGN_UL

#

## Tags

todo |

### ALIGN_UC

    ALIGN_UC

#

## Tags

todo |

### ALIGN_UR

    ALIGN_UR

#

## Tags

todo |

### ALIGN_ML

    ALIGN_ML

#

## Tags

todo |

### ALIGN_MC

    ALIGN_MC

#

## Tags

todo |

### ALIGN_MR

    ALIGN_MR

#

## Tags

todo |

### ALIGN_LL

    ALIGN_LL

#

## Tags

todo |

### ALIGN_LC

    ALIGN_LC

#

## Tags

todo |

### ALIGN_LR

    ALIGN_LR

#

## Tags

todo |

### ERROR_NOTREADY

    ERROR_NOTREADY

#

## Tags

todo |

### ERROR_BADFILE

    ERROR_BADFILE

#

## Tags

todo |

### ERROR_BADFILETYPE

    ERROR_BADFILETYPE

#

## Tags

todo |

### ERROR_NOFILE

    ERROR_NOFILE

#

## Tags

todo |

### ERROR_CREATEWM

    ERROR_CREATEWM

#

## Tags

todo |

### ERROR_LOADIMG

    ERROR_LOADIMG

#

## Tags

todo |

### ERROR_OTHER

    ERROR_OTHER

#

## Tags

todo |

## Methods

### __construct()

    __construct()

Construct a new cg_watermark object.

#

## Tags

todo |

### get_error()

    get_error() : string

Return any error from the last watermark operation.

#### Returns

string

#

## Tags

todo |

### 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 |

#

## Tags

todo |

### set_watermark_image()

    set_watermark_image(string $filename)

Set the watermark image.

This will reset any watermark text.

#### Parameters

string | $filename |

#

## Tags

todo |

### set_alignment()

    set_alignment(string $alignment)

Set the alignment for the watermark text or image.

#### Parameters

string | $alignment | One of the alignment constants.

#

## Tags

todo |

### get_alignment()

    get_alignment()

Get the alignment (if any) for this watermarking.

The default value is ALIGN_MC

#

## Tags

todo |

### set_font()

    set_font(string $font)

Set the font for text based watermarks.

#### Parameters

string | $font |

#

## Tags

todo |

### 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.

#

## Tags

todo |

### 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

#

## Tags

todo |

### 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)

#

## Tags

todo |

### 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.

#

## Tags

todo |

### 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.

#

## Tags

todo |

### is_ready()

    is_ready() : bool

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

#### Returns

bool

#

## Tags

todo |

### 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

#

## Tags

todo |

### class.cg_watermark.php