media

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TODO: those are duplicates of mime types in mime package because of cyclical imports: fix
	ContentTypeOctetStream = "application/octet-stream"
	ContentTypeTextPlain   = "text/plain"
	ContentTypeTextHTML    = "text/html"
	ContentTypeImageJPEG   = "image/jpeg"
	ContentTypeImageBMP    = "image/bmp"
	ContentTypeImagePNG    = "image/png"
	ContentTypeImageGIF    = "image/gif"
	ContentTypeImageWEBP   = "image/webp"
	ContentTypeZip         = "application/zip"
)

Variables

View Source
var (
	//go:embed testdata/cat.jpg
	Cat []byte
	//go:embed testdata/panda.jpg
	Panda []byte
	//go:embed testdata/chamillion.jpg
	Chamillion []byte
)
View Source
var ErrCyclicalImport = errors.New("cyclical import of dependencies")

Functions

func AppendPathPrefixToExternalRecipientListEntries

func AppendPathPrefixToExternalRecipientListEntries(prefix string, recipientEntry any) any

func DeterministicHashStringOf

func DeterministicHashStringOf(data []byte) string

func EncodeJPEG

func EncodeJPEG(image image.Image, quality int) ([]byte, error)

func EncodePNG

func EncodePNG(image image.Image) ([]byte, error)

func IsPathLocal

func IsPathLocal(p string) bool

func IsPathLocalBytes

func IsPathLocalBytes(p []byte) bool

func IsRecipientEntryExternal

func IsRecipientEntryExternal(p string) bool

func NewCyclicalImportPreventingFileSystem

func NewCyclicalImportPreventingFileSystem(
	fs fs.FS,
) fs.FS

func NewUnsafeUnconstrainedFileSystem

func NewUnsafeUnconstrainedFileSystem() fs.FS

func Resize

func Resize(image image.Image, width, height uint) image.Image

Types

type Constraints

type Constraints struct {
	Width   int
	Height  int
	Quality int
}

func (Constraints) ApplyTo

func (m Constraints) ApplyTo(b []byte) (_ []byte, contentType string, err error)

func (Constraints) WithResolution

func (m Constraints) WithResolution(resolution int) Constraints

Jump to

Keyboard shortcuts

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