UNPKG

stable-diffusion-client

Version:
37 lines (36 loc) 1.18 kB
import { sharp } from "../deps.js"; import { ApiRawResponse } from "../../mod.js"; /** * @class StableDiffusionResult * @classdesc Result of a Stable Diffusion image processing API call * @param {StableDiffusionApiRawResponse} Raw axios response * @property {sharp.Sharp} image - First sharp image from the result list * @property {sharp.Sharp[]} images - List of sharp images * @property {any} info - Info object * @property {any} parameters - Parameters object * @property {AxiosApiRawResponse} response - Raw response from the API * @example * const api = new StableDiffusionApi() * const result = await api.txt2img({ * prompt: "The brain of a computer", * }) * * // Save the first image * result.image.toFile("result.png") * * // Save all images * result.images.map((image, i) => { * image.toFile(`result_${i}.png`) * }) */ export default class StableDiffusionResult<PARAMETER, INFO> { data: ApiRawResponse; images: string[]; info: INFO | { html_info: string; }; parameters: PARAMETER; constructor(data: ApiRawResponse); static base64toSharp(base64: string): sharp.Sharp; getSharpImage(id: number): sharp.Sharp; }