protected function callFunction($prefix, $format, array $arguments)
    {
        $function = "$prefix$format";

        if (!in_array($format, $this->getSupportedFormats())) {
            throw new RuntimeException("Unsupported image format $format");
        }

        if (!function_exists($function)) {
            throw new BadFunctionCallException("Function $function does not exist");
        }

        return call_user_func_array($function, $arguments);
    }