Documentation ¶
Index ¶
- Constants
- Variables
- func BuildResponse(w http.ResponseWriter, imagePath string, contentType string) error
- func CompressByDSSIM(original *image.Image, newImgFile io.Writer, handler *ImageHandler, ...) error
- func Dispatch(request *http.Request, response *http.Response, ...) (string, string, error)
- func DownloadImage(originalUrl string, cacheDelay int, allowed_domains []string) (*http.Response, error)
- func GetAllImageHandlers() map[string]ImageHandler
- func GetAllImageHandlersByExtension() map[string]ImageHandler
- func IsImage(response *http.Response) bool
- func Optimize(response *http.Response, imageParameters *ImageParameters, options *Options) (string, string, error)
- func RemoveImageHandlerFromAutoConf(autoConfPath string, imageType string) error
- func StartHttpCachePurge(checkIntervalSeconds int) chan bool
- type AvifHandler
- type ImageHandler
- func AutoImageHandler(clientRequest *http.Request, imageResponse *http.Response, autoConfPath string, ...) (ImageHandler, error)
- func NewImageHandler(imageType string) (ImageHandler, error)
- func NewImageHandlerByBytes(buffer io.Reader) (ImageHandler, error)
- func NewImageHandlerByExtension(extension string) (ImageHandler, error)
- type ImageParameters
- type JPEGHandler
- type OptimizationResult
- type Options
- type PNGHandler
- type WebPHandler
- type WebPLosslessHandler
- type WorkerManager
Constants ¶
View Source
const MaxIterations = 4
Variables ¶
View Source
var FileMutex sync.Map
View Source
var HttpCacheMutex sync.Map
Functions ¶
func BuildResponse ¶
func BuildResponse(w http.ResponseWriter, imagePath string, contentType string) error
func CompressByDSSIM ¶
func DownloadImage ¶
func GetAllImageHandlers ¶
func GetAllImageHandlers() map[string]ImageHandler
func GetAllImageHandlersByExtension ¶
func GetAllImageHandlersByExtension() map[string]ImageHandler
func StartHttpCachePurge ¶
Types ¶
type AvifHandler ¶
type AvifHandler struct {
ImageHandler
}
func (*AvifHandler) ImageExtension ¶
func (a *AvifHandler) ImageExtension() string
func (*AvifHandler) ImageType ¶
func (a *AvifHandler) ImageType() string
func (*AvifHandler) SupportsTransparency ¶
func (a *AvifHandler) SupportsTransparency() bool
type ImageHandler ¶
type ImageHandler interface { ImageType() string ImageExtension() string SupportsTransparency() bool Decode(reader io.Reader) (image.Image, error) Encode(newImgFile io.Writer, newImage image.Image, quality uint) error }
func AutoImageHandler ¶
func NewImageHandler ¶
func NewImageHandler(imageType string) (ImageHandler, error)
func NewImageHandlerByBytes ¶
func NewImageHandlerByBytes(buffer io.Reader) (ImageHandler, error)
func NewImageHandlerByExtension ¶
func NewImageHandlerByExtension(extension string) (ImageHandler, error)
type ImageParameters ¶
type ImageParameters struct { Width uint Height uint Quality uint AdaptiveQuality bool Convert string }
ImageParameters represents the parameters for optimization
func Parser ¶
func Parser(name string) (ImageParameters, error)
Parser extracts width, height and quality from the provided parameters.
func (*ImageParameters) GenerateHash ¶
func (imParams *ImageParameters) GenerateHash(response *http.Response) string
func (*ImageParameters) GetUrlString ¶
func (imParams *ImageParameters) GetUrlString() string
type JPEGHandler ¶
type JPEGHandler struct {
ImageHandler
}
func (*JPEGHandler) ImageExtension ¶
func (j *JPEGHandler) ImageExtension() string
func (*JPEGHandler) ImageType ¶
func (j *JPEGHandler) ImageType() string
func (*JPEGHandler) SupportsTransparency ¶
func (j *JPEGHandler) SupportsTransparency() bool
type OptimizationResult ¶
type OptimizationResult struct {
// contains filtered or unexported fields
}
type PNGHandler ¶
type PNGHandler struct {
ImageHandler
}
func (*PNGHandler) ImageExtension ¶
func (p *PNGHandler) ImageExtension() string
func (*PNGHandler) ImageType ¶
func (p *PNGHandler) ImageType() string
func (*PNGHandler) SupportsTransparency ¶
func (p *PNGHandler) SupportsTransparency() bool
type WebPHandler ¶
type WebPHandler struct {
ImageHandler
}
func (*WebPHandler) ImageExtension ¶
func (w *WebPHandler) ImageExtension() string
func (*WebPHandler) ImageType ¶
func (w *WebPHandler) ImageType() string
func (*WebPHandler) SupportsTransparency ¶
func (w *WebPHandler) SupportsTransparency() bool
type WebPLosslessHandler ¶
type WebPLosslessHandler struct {
WebPHandler
}
func (*WebPLosslessHandler) ImageExtension ¶
func (w *WebPLosslessHandler) ImageExtension() string
type WorkerManager ¶
type WorkerManager struct {
// contains filtered or unexported fields
}
var GlobalWorkerManager *WorkerManager
func NewWorkerManager ¶
func NewWorkerManager() *WorkerManager
func (*WorkerManager) Close ¶
func (w *WorkerManager) Close()
func (*WorkerManager) Dispatch ¶
func (w *WorkerManager) Dispatch(response *http.Response, imageParameters *ImageParameters, options *Options) chan output
func (*WorkerManager) Run ¶
func (w *WorkerManager) Run()
Click to show internal directories.
Click to hide internal directories.