public function canvas($width, $height, $mode = null, $x = null, $y = null, $bg = null) {
        if (!$width || !$height) {
            throw new InvalidArgumentException('width and height must be specified');
        }

        $params = array(
            'width=' . (int) $width,
            'height=' . (int) $height,
        );

        if ($mode) {
            $params[] = 'mode=' . $mode;
        }

        if ($x) {
            $params[] = 'x=' . (int) $x;
        }

        if ($y) {
            $params[] = 'y=' . (int) $y;
        }

        if ($bg) {
            $params[] = 'bg=' . $bg;
        }

        return $this->addTransformation(sprintf('canvas:%s', implode(',', $params)));
    }