gallery

package
v0.0.0-...-5354b93 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EXIF

func EXIF(r io.Reader) (*exif.Exif, error)

EXIF returns exif metadata from a reader.

func NewGalleryAPI

func NewGalleryAPI(source Source, cache Cache) http.Handler

NewGalleryAPI returns a new http.Handler instance that implements gallery related endpoints.

func Thumbnail

func Thumbnail(r io.Reader, maxHeight uint) (io.Reader, error)

Thumbnail returns thubmnail from a reader constrained by maxHeight.

Types

type Album

type Album struct {
	Name       string    `json:"name"`
	ModTime    time.Time `json:"updated_at"`
	ItemsCount int       `json:"items_count"`
}

Album stores album metadata.

type Cache

type Cache interface {
	// Returns thumbnail and modtime for a given image path if it exists, otherwise returns nil.
	Thumbnail(gallery, image string) (io.ReadSeeker, time.Time)
	// Stores thumbnail for a given image path and returns reader for a stored thumbnail.
	StoreThumbnail(gallery, image string, r io.Reader) (io.ReadSeeker, error)
}

Cache caches gallery metadata.

func NewDiskCache

func NewDiskCache(dir string) (Cache, error)

NewDiskCache returns a new Cache instance that uses filesystem. dir will be created if necessary.

type Image

type Image struct {
	Name    string    `json:"name"`
	Path    string    `json:"path"`
	ModTime time.Time `json:"updated_at"`
}

Image stores image metadata.

type Source

type Source interface {
	// Albums returns list of all albums in a Source.
	Albums() ([]Album, error)
	// Images returns images metadata for a given album.
	Images(album string) ([]Image, error)
	// Image returns image file for a given image path.
	Image(ablum, image string) (*os.File, error)
}

Source provides album and images metadata.

func NewDiskSource

func NewDiskSource(basePath string, imgExtensions []string) (Source, error)

NewDiskSource returns disk based source for a provided base dir path. Only images with requested extensions are returned.

Jump to

Keyboard shortcuts

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