public function imageFilter($filter, $arg1 = false, $arg2 = false, $arg3 = false, $arg4 = false)
    {
        if (!is_numeric($filter)) {
            throw new \InvalidArgumentException('$filter must be numeric');
        }

        if (!function_exists('imagefilter')) {
            throw new \RuntimeException('Your version of GD does not support image filters');
        }

        $result = false;
        if ($arg1 === false) {
            $result = imagefilter($this->oldImage, $filter);
        } elseif ($arg2 === false) {
            $result = imagefilter($this->oldImage, $filter, $arg1);
        } elseif ($arg3 === false) {
            $result = imagefilter($this->oldImage, $filter, $arg1, $arg2);
        } elseif ($arg4 === false) {
            $result = imagefilter($this->oldImage, $filter, $arg1, $arg2, $arg3);
        } else {
            $result = imagefilter($this->oldImage, $filter, $arg1, $arg2, $arg3, $arg4);
        }

        if (!$result) {
            throw new \RuntimeException('GD imagefilter failed');
        }

        $this->workingImage = $this->oldImage;

        return $this;
    }