public function crop($x = null, $y = null, $width = null, $height = null, $mode = null) {
        if ($mode === null && ($x === null || $y === null)) {
            throw new InvalidArgumentException('x and y needs to be specified without a crop mode');
        }

        if ($mode === 'center-x' && $y === null) {
            throw new InvalidArgumentException('y needs to be specified when mode is center-x');
        }

        if ($mode === 'center-y' && $x === null) {
            throw new InvalidArgumentException('x needs to be specified when mode is center-y');
        }

        if ($width === null || $height === null) {
            throw new InvalidArgumentException('width and height needs to be specified');
        }

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

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

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

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

        return $this->addTransformation('crop:' . implode(',', $params));
    }