medias

package
v0.0.0-...-2e1bc12 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MimeType

func MimeType(extension string) string

MimeType returns the mime type for common web file extensions.

Types

type Converter

type Converter interface {
	OnPreGeneration(func(cmd string, args ...string))
	ToAVIF(src, dest string, dimensions Dimensions) error
	ToMP3(src, dest string) error
	ToWebM(src, dest string) error
}

type Dimensions

type Dimensions struct {
	Width  int
	Height int
}

Dimensions regroups the width and height of an image.

func OriginalSize

func OriginalSize() Dimensions

func ReadImageDimensions

func ReadImageDimensions(path string) (Dimensions, error)

ReadImageDimensions extracts the dimensions from a GIF/PNG/JPEG file.

func ResizeTo

func ResizeTo(maxWidthOrHeight int) Dimensions

func (Dimensions) Landscape

func (d Dimensions) Landscape() bool

func (Dimensions) LargerThan

func (d Dimensions) LargerThan(widthOrHeight int) bool

LargerThan returns if at least one dimension exceeds the given size. LargerThan is conservatrice and returns true if dimensions are not available.

func (Dimensions) Portrait

func (d Dimensions) Portrait() bool

func (Dimensions) String

func (d Dimensions) String() string

func (Dimensions) Zero

func (d Dimensions) Zero() bool

Zero returns if the dimensions are not available.

type FFmpegConverter

type FFmpegConverter struct {
	// contains filtered or unexported fields
}

func NewFFmpegConverter

func NewFFmpegConverter(preset string) (*FFmpegConverter, error)

func (*FFmpegConverter) OnPreGeneration

func (c *FFmpegConverter) OnPreGeneration(fn func(cmd string, args ...string))

func (*FFmpegConverter) ToAVIF

func (c *FFmpegConverter) ToAVIF(srcPath string, destPath string, dimensions Dimensions) error

ConvertToAVIF convert a picture to AVIF format. Requirements:

brew install ffmpeg

func (*FFmpegConverter) ToMP3

func (c *FFmpegConverter) ToMP3(srcPath string, destPath string) error

func (*FFmpegConverter) ToWebM

func (c *FFmpegConverter) ToWebM(srcPath string, destPath string) error

type RandomConverter

type RandomConverter struct{}

RandomConverter generates files containing fake data. Useful in tests to avoid waiting for a command like ffmpeg to finish.

func NewRandomConverter

func NewRandomConverter() *RandomConverter

func (*RandomConverter) OnPreGeneration

func (c *RandomConverter) OnPreGeneration(fn func(cmd string, args ...string))

func (*RandomConverter) ToAVIF

func (c *RandomConverter) ToAVIF(src, dest string, dimensions Dimensions) error

func (*RandomConverter) ToMP3

func (c *RandomConverter) ToMP3(src, dest string) error

func (*RandomConverter) ToWebM

func (c *RandomConverter) ToWebM(src, dest string) error

Jump to

Keyboard shortcuts

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