media

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2023 License: Apache-2.0 Imports: 14 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")
)

Functions

func ImageFromBytes added in v0.0.4

func ImageFromBytes(b []byte) (img image.Image, err error)

func ImageFromReader added in v0.0.4

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

func MakePhash

func MakePhash(filename string) (b []byte, err error)

func MakeThumb

func MakeThumb(in io.Reader, out io.Writer, maxDimension int) error

func MakeThumbFromFile added in v0.0.5

func MakeThumbFromFile(filepath string, out io.Writer, maxDimension int) error

func OpenImage

func OpenImage(filename string) (img image.Image, err error)

OpenImage opens a media file from disk and attempts to decode it into an image.Image. If the file is not an image, it will be passed to MakeThumbnail to generate a thumbnail. This function currently only returns thumbnails in case of non StdImage media. Either change the function name or make an ffmpeg command which returns first frame of video/decodes image to jpg.

For this package, this functionality with thumbnails is preferred.

func Phash added in v0.0.4

func Phash(r io.Reader) (b []byte, err error)

func ReduceImageSize added in v0.0.4

func ReduceImageSize(img image.Image, w io.Writer, maxDimension int) error

func ResizeImage

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

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

func RunFfmpeg

func RunFfmpeg(r io.Reader, w io.Writer, args ...string) error

func SetPhashScale added in v0.0.4

func SetPhashScale(scale int)

Types

type Phasher added in v0.0.4

type Phasher struct {
	Scale int
}

func DefaultPhasher added in v0.0.4

func DefaultPhasher() *Phasher

func (Phasher) GeneratePhash added in v0.0.4

func (p Phasher) GeneratePhash(img image.Image) []byte

GeneratePhash returns a basic perceptual hash of the given image.

Jump to

Keyboard shortcuts

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