export type GetApiInstancesIdRenderedArgs = {height?: number | undefined, quality?: number | undefined, returnUnsupportedImage?: boolean | undefined, smooth?: boolean | undefined, width?: number | undefined, 'window-center'?: number | undefined, 'window-width'?: number | undefined, Accept?: string | undefined, id: string}; export type GetApiInstancesIdRenderedOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Render an image * * GET /instances/{id}/rendered */ export const getApiInstancesIdRendered = async (args: GetApiInstancesIdRenderedArgs, options?: GetApiInstancesIdRenderedOptions) => { const {baseUrl = "https://orthanc.uclouvain.be/demo", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "image/jpeg") if (args.height != null) query.append("height", String(args.height)) if (args.quality != null) query.append("quality", String(args.quality)) if (args.returnUnsupportedImage != null) query.append("returnUnsupportedImage", String(args.returnUnsupportedImage)) if (args.smooth != null) query.append("smooth", String(args.smooth)) if (args.width != null) query.append("width", String(args.width)) if (args['window-center'] != null) query.append("window-center", String(args['window-center'])) if (args['window-width'] != null) query.append("window-width", String(args['window-width'])) if (args.Accept != null) headers.set("Accept", String(args.Accept)) const url = `${baseUrl.replace(/\/+$/, '')}/instances/${encodeURIComponent(String(args.id))}/rendered${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };