go-imageflux
URL builder and parser for ImageFlux.
Usage
ImageFlux is Image Conversion & Distribution Engine.
This allows you to easily generate images optimized for each device based on a single source image,
and delivers them quickly and with high quality.
The imageflux package builds and parse URLs for ImageFlux.
Build URL
In ImageFlux, parameters for image transformation are embedded in the URL.
proxy := &imageflux.Proxy{
Host: "demo.imageflux.jp",
}
cfg := &imageflux.Config{
Width: 200,
Format: imageflux.FormatWebPAuto,
}
u := proxy.Image("/images/1.jpg", cfg).SignedURL()
fmt.Println(u)
Build Signed URL
By attaching a signature to the transformation parameters,
it prevents third parties from rewriting the URL.
proxy := &imageflux.Proxy{
Host: "demo.imageflux.jp",
Secret: "testsigningsecret",
}
cfg := &imageflux.Config{
Width: 200,
}
u := proxy.Image("/images/1.jpg", cfg).SignedURL()
fmt.Println(u)
Parse URL
proxy := &imageflux.Proxy{}
image, err := proxy.Parse("/c/w=200/images/1.jpg", "")
if err != nil {
log.Fatal(err)
}
fmt.Printf("path = %s\n", image.Path)
fmt.Printf("width = %d\n", image.Config.Width)
References