thumbnailer

package
v0.0.0-...-485e05f Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrThumbYamlNotFound = fmt.Errorf(".thumbs.yml not found")

Functions

func GenerateThumbnail

func GenerateThumbnail(media []*Media, dir, format string) ([]byte, error)

func GenerateThumbnails

func GenerateThumbnails(
	uploader Uploader,
	media []*Media,
	dir string,
	format string,
	force bool,
) ([]string, error)

func ProcessDirectory

func ProcessDirectory(dir string, up Uploader, force bool) ([]string, error)

func SaveThumbsFile

func SaveThumbsFile(path string, media []*Media) error

func ScanDirectory

func ScanDirectory(dir string) ([]string, error)

Types

type ByThumbHeightDesc

type ByThumbHeightDesc []MediaContainer

func (ByThumbHeightDesc) Len

func (a ByThumbHeightDesc) Len() int

func (ByThumbHeightDesc) Less

func (a ByThumbHeightDesc) Less(i, j int) bool

func (ByThumbHeightDesc) Swap

func (a ByThumbHeightDesc) Swap(i, j int)

type Media

type Media struct {
	Path                string
	Width               int    `yaml:"width,omitempty"`
	Height              int    `yaml:"height,omitempty"`
	ThumbPath           string `yaml:"thumb,omitempty"`
	ThumbXOffset        int    `yaml:"thumb_x,omitempty"`
	ThumbYOffset        int    `yaml:"thumb_y,omitempty"`
	ThumbWidth          int    `yaml:"thumb_width,omitempty"`
	ThumbHeight         int    `yaml:"thumb_height,omitempty"`
	ThumbTotalWidth     int    `yaml:"thumb_total_width,omitempty"`
	ThumbTotalHeight    int    `yaml:"thumb_total_height,omitempty"`
	Blurhash            string `yaml:"blurhash,omitempty"`
	BlurhashImageBase64 string `yaml:"blurhash_image_base64,omitempty"`
	// contains filtered or unexported fields
}

Media struct for items in .thumbs.yml file.

func LoadThumbsFile

func LoadThumbsFile(path string) ([]*Media, error)

func UploadNewMedia

func UploadNewMedia(
	uploader Uploader,
	media []*Media,
	files []string,
	dir string,
) ([]*Media, error)

type MediaContainer

type MediaContainer struct {
	Media *Media
}

MediaContainer is a wrapper for Photo struct, used for sorting, so that references are not swapped and still can be modified.

type Uploader

type Uploader interface {
	Upload(key string, body []byte) error
}

Jump to

Keyboard shortcuts

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