Documentation
¶
Index ¶
- func ExpectedExt(srcPath string) string
- func IsUpToDate(srcPath string, variants image.Variant, outputDir string) bool
- func IsVector(srcPath string) bool
- func ProcessImage(src ParsedAsset, outputDir string, quality int, log func(...any)) ([]string, error)
- func VectorOutputName(srcPath string) string
- type Config
- type Handler
- func (h *Handler) LoadImages() error
- func (h *Handler) Logger(messages ...any)
- func (h *Handler) Name() string
- func (h *Handler) ReloadModule(moduleDir string) error
- func (h *Handler) SetFinder(f *modfind.Finder)
- func (h *Handler) SetLog(fn func(messages ...any))
- func (h *Handler) UnobservedFiles() []string
- type ParsedAsset
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExpectedExt ¶ added in v0.0.20
ExpectedExt is the extension ProcessImage will write for src — the single answer the whole pipeline asks, so that "is this output current?" and "is this output an orphan?" cannot disagree with what the encoder actually produces. Treating both extensions as equally valid is what let a lossless .webp written by an older release survive next to the .jpg that replaced it: each variant appeared up to date because SOME file matched, and cleanup spared the stale one because SOME asset could have claimed it.
A JPEG source needs no decode: the format has no alpha channel, so it is opaque by construction. Anything else has to be read. An unreadable source returns "", meaning "unknown" — callers then fall back to accepting either extension rather than deleting output they cannot reason about.
func IsVector ¶ added in v0.0.21
IsVector responde si la fuente se entrega tal cual en vez de codificarse.
Existe porque un logo vectorial no tiene dónde vivir en un pipeline que solo sabía convertir mapas de bits: quedaba fuera de image.Asset y cada sitio se escribía su propio copiador de archivos. Ese copiador era invisible para el demonio, así que el mismo proyecto servía el logo en release y devolvía 404 en desarrollo.
func ProcessImage ¶
func VectorOutputName ¶ added in v0.0.21
VectorOutputName es el nombre con el que un vector aterriza en la salida: el suyo, sin sufijo de variante. La página lo referencia por ese nombre.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func (*Handler) LoadImages ¶
LoadImages discovers modules via go list and processes their images.
func (*Handler) ReloadModule ¶
ReloadModule re-extracts and re-processes images for a single module.
func (*Handler) UnobservedFiles ¶
type ParsedAsset ¶
type ParsedAsset struct {
AbsPath string // absolute path: moduleDir + "/" + asset.Path
Variants image.Variant // resolved bitmask value
Alt string
BaseName string // base name without extension: "logo", "hero"
}
func ExtractImages ¶
func ExtractImages(moduleDir string) ([]ParsedAsset, error)