encode

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 19, 2026 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package encode produces base64 data URIs for inline file and image payloads. Encode, EncodeFile, EncodeImage and the ImageFormat values are re-exported from the top-level fal package. ImageFormat lives here (rather than in upload) because both encode.EncodeImage and upload's UploadImage take it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode

func Encode(data []byte, contentType string) string

Encode returns a base64 data URI for the given bytes. It mirrors fal_client.encode.

func EncodeFile

func EncodeFile(path string) (string, error)

EncodeFile reads a file and returns a base64 data URI, detecting the content type from the extension. It mirrors fal_client.encode_file.

func EncodeImage

func EncodeImage(img image.Image, format ImageFormat) (string, error)

EncodeImage encodes an image and returns a base64 data URI. It mirrors fal_client.encode_image.

Pass FormatJPEG or FormatPNG for an explicit, self-documenting call. The zero value (empty ImageFormat) defaults to JPEG, matching fal_client.encode_image's format="jpeg" default.

Types

type ImageFormat

type ImageFormat string

ImageFormat selects the wire encoding for an image. The zero value encodes as JPEG, matching the Python client's format="jpeg" default.

const (
	FormatJPEG ImageFormat = "jpeg"
	FormatPNG  ImageFormat = "png"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL