media

package module
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoMIME          = errors.New("no mime could be detected")
	ErrUnsupportedMIME = errors.New("detected mime is unsupported")
	ErrFFMPEGNotFound  = errors.New("ffmpeg not found in PATH")
)
View Source
var CntMasks = map[Kind][]string{
	IMAGE: {".jpg", ".jpeg", ".png", ".apng", ".gif", ".bmp", ".webp", ".avif", ".jxl", ".tiff"},
	VIDEO: {".mp4", ".m4v", ".webm", ".mkv", ".avi", ".mov", ".mpg", ".mpeg"},
	AUDIO: {".m4a", ".opus", ".ogg", ".mp3", ".flac", ".wav", ".aac"},
}
View Source
var ExtToMaskMap = map[string]Kind{}

Functions

func CapImageSize added in v0.0.7

func CapImageSize(img image.Image, maxSize int) *image.RGBA

CapImageSize creates an empty RGBA image with the same aspect ration as the input, but capped to the maxSize provided, such that neither height nor width are above that value.

edge cases:

  • source file very tall, very wide, resulting in an unusable image or a very large filesize

func Draw added in v0.0.7

func Draw(src image.Image, dst *image.RGBA, quality bool)

Draw copies src to dst, using either a fast algorithm, or a quality algorithm.

func FlushImage added in v0.0.7

func FlushImage(tar io.Writer, img image.Image, quality int) error

func GeneratePhash

func GeneratePhash(img image.Image, scale int) []byte

GeneratePhash returns a basic perceptual hash of the given image.

func ImageFromReader added in v0.0.4

func ImageFromReader(r io.Reader) (img image.Image, err error)

func Is added in v0.0.7

func Is(kinds ...Kind) func(key string) bool

func MinImageSize added in v0.0.8

func MinImageSize(img image.Image, maxSize int) *image.RGBA

MinImageSize cap the smaller dimension to maxSize while maintaining aspect ration.

func ReduceImageSize added in v0.0.4

func ReduceImageSize(img image.Image, maxDimension int) *image.RGBA

func RegisterMasks added in v0.0.7

func RegisterMasks(mask Kind, keys ...string)

func ResizeImage

func ResizeImage(img image.Image, width, height int) *image.RGBA

ResizeImage resizes the given image to the specified width and height.

Types

type Kind added in v0.0.7

type Kind uint64
const (
	INVALID Kind = 1 << iota
	IMAGE
	VIDEO
	AUDIO
)

func GetKind added in v0.0.7

func GetKind(ext string) Kind

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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