Reference Manuals

Canvas

Canvas — Resize the image canvas

Canvas is part of the Gallery package.

Synopsis

class Canvas implements Transform {
        private        array               $color
        private        int                 $height
        private        int                 $offset_x
        private        int                 $offset_y
        private        int                 $width

        public         Canvas              __construct               ( int $width,
                                                                       int $height,
                                                                       int $offset_x,
                                                                       int $offset_y,
                                                                       array $color );
        public         resource            apply                     ( resource $image,
                                                                        &$image );
}

Object Hierarchy

Canvas

Implemented Interfaces

Canvas implements Transform

Description

Resize the image canvas

Attribute Details

$color

private        array          $color

An array of three elements for the color in RGB

Default value: empty string


$height

private        int            $height

The height of the new image canvas

Default value: empty string


$offset_x

private        int            $offset_x

The X offset of the original image

Default value: empty string


$offset_y

private        int            $offset_y

The Y offset of the original image

Default value: empty string


$width

private        int            $width

The width of the new image canvas

Default value: empty string

Method Details

__construct()

public         Canvas         __construct               ( int $width,
                                                          int $height,
                                                          int $offset_x,
                                                          int $offset_y,
                                                          array $color );

Create a new Canvas object

To center the image on the new canvas, pass NULL to the $offset_x and/or $offset_y. Offsets can also be negative.

$width
The width of the new canvas
$height
The height of the new canvas
$offset_x
X offset of the original image on the canvas
$offset_y
Y offset of the original image on the canvas
$color
An array containing 3 integer elements representing the color in RGB

apply()

public         resource       apply                     ( resource $image,
                                                           &$image );

Put the image on the new canvas

$image
&$image