Documentation
¶
Overview ¶
Package imageoutput saves base64 Images API responses to local image files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckName ¶
CheckName probes actual filesystem limits before requesting images. The directory must already exist and the name must already be normalized. Empty names use the short timestamp fallback and do not need a separate probe.
func NameFromPrompt ¶
NameFromPrompt makes a short filename stem from the description. It retains Unicode letters, numbers and their combining marks, dropping only an initial English article. The result contains no extension or path components. Empty results let the caller retain its usual timestamp fallback.
func NormalizeName ¶
NormalizeName strips one familiar image suffix. The response's actual format supplies the extension when saving; names may not contain path components.
func ResolveDirectory ¶
ResolveDirectory returns an absolute, writable output directory. It creates the default directory, but requires a caller-selected directory to exist.
func ValidateName ¶
ValidateName checks a filename stem against supported platforms' restrictions.
Types ¶
type SavedImage ¶ added in v1.26.0
SavedImage identifies the bytes successfully written by the save operation. SHA256 lets an optional preview verify a reopened file before decoding it.
func SaveResponse ¶
func SaveResponse(ctx context.Context, raw []byte, directory string, name ...string) (saved []SavedImage, err error)
SaveResponse saves every base64 image, returning completed files in response order even if siblings fail. Only incomplete files are removed. Cancellation stops the batch. URL responses are not downloaded. An omitted name uses local date/time; collisions receive -2, -3, and subsequent suffixes.