Documentation
¶
Overview ¶
Package manikyr provides a sensible and filesystem structure agnostic image thumbnailing automation.
Index ¶
- Variables
- func NthSubdir(root, dir string, n int) (bool, error)
- func Subdirectories(root string) ([]string, error)
- type Event
- type EventType
- type Manikyr
- func (m *Manikyr) AddRoot(root string, evtChan chan Event) error
- func (m *Manikyr) AddSubdir(root, subdir string)
- func (m *Manikyr) EmitEvent(root string, t EventType, path string, err error)
- func (m *Manikyr) HasRoot(root string) bool
- func (m *Manikyr) Init(root string) error
- func (m *Manikyr) RemoveRoot(root string) error
- func (m *Manikyr) RemoveSubdir(root, subdir string) error
- func (m *Manikyr) Roots() []string
- func (m *Manikyr) SetThumbAlgorithm(filter imaging.ResampleFilter)
- func (m *Manikyr) SetThumbDirFileMode(fm uint32)
- func (m *Manikyr) SetThumbSize(w, h int)
- func (m *Manikyr) ThumbAlgorithm() imaging.ResampleFilter
- func (m *Manikyr) ThumbDirFileMode() os.FileMode
- func (m *Manikyr) ThumbSize() (int, int)
Constants ¶
This section is empty.
Variables ¶
var ( ErrRootNotWatched = errors.New("root is not watched") ErrRootWatched = errors.New("root is already watched") NearestNeighbor = imaging.NearestNeighbor Box = imaging.Box Linear = imaging.Linear Hermite = imaging.Hermite MitchellNetravali = imaging.MitchellNetravali CatmullRom = imaging.CatmullRom BSpline = imaging.BSpline Gaussian = imaging.Gaussian Bartlett = imaging.Bartlett Lanczos = imaging.Lanczos Hann = imaging.Hann Hamming = imaging.Hamming Blackman = imaging.Blackman Welch = imaging.Welch Cosine = imaging.Cosine )
Functions ¶
func Subdirectories ¶
Types ¶
type Manikyr ¶
type Manikyr struct { ThumbDirGetter func(string) string ThumbNameGetter func(string) string ShouldCreateThumb func(string, string) bool ShouldWatchSubdir func(string, string) bool // contains filtered or unexported fields }
Manikyr watches specified directory roots for changes. If a new file matching the rules the user has set is created, it will get watched (directory), or thumbnailed (regular file) to a dynamic location with the chosen dimensions and algorithm. Subdirectory unwatching on deletion is automatic.
func New ¶
func New() *Manikyr
New creates a new Manikyr instance which holds a set of preferences and directory roots to apply those rules to. Default values should be kept safe, as in not doing any damage to the filesystem integrity if the instance is initialized as is.
func (*Manikyr) AddRoot ¶
AddRoot adds and watches specified path as a new root, piping future errors to given channel. The error returned considers the watcher creation, not function.
func (*Manikyr) AddSubdir ¶
AddSubdir adds a subdirectory to a root watcher. Both paths should be absolute.
func (*Manikyr) Init ¶
Init watches and thumbnail existing files as if they were added after the root directory got watched. Regular files are checked for corresponding thumbnails before creating a new one.
func (*Manikyr) RemoveRoot ¶
RemoveRoot removes the named root directory path and unwatches it. A root should always be unwatched this way prior to actual path deletion in the filesystem. If the named path was not previously specified to be a root, a non-nil error is returned.
func (*Manikyr) RemoveSubdir ¶
RemoveSubdir removes a subdirectory from a root watcher. Both paths should be absolute.
func (*Manikyr) SetThumbAlgorithm ¶
func (m *Manikyr) SetThumbAlgorithm(filter imaging.ResampleFilter)
SetThumbAlgorithm sets the used algorithm for thumbnail creation. See http://godoc.org/github.com/disintegration/imaging#ResampleFilter for more info.
func (*Manikyr) SetThumbDirFileMode ¶
SetThumbDirFileMode sets the filemode for thumbnail directories.
func (*Manikyr) SetThumbSize ¶
Set thumbnail dimensions. Dimensions should be positive.
func (*Manikyr) ThumbAlgorithm ¶
func (m *Manikyr) ThumbAlgorithm() imaging.ResampleFilter
ThumbAlgorithm gets the currently used algorithm for thumbnail creation.
func (*Manikyr) ThumbDirFileMode ¶
ThumbDirFileMode gets the currently set filemode for thumbnail directories.