Documentation ¶
Index ¶
- Constants
- Variables
- func Generate(p Params, signer Signer) string
- func GeneratePath(p Params) string
- func GenerateUnsafe(p Params) string
- func Normalize(image string, safeChars SafeChars) string
- type Filter
- type Filters
- type Params
- type ResultStorageHasher
- type ResultStorageHasherFunc
- type SafeChars
- type Signer
- type StorageHasher
- type StorageHasherFunc
Constants ¶
const ( // TrimByTopLeft trim by top-left keyword TrimByTopLeft = "top-left" // TrimByBottomRight trim by bottom-right keyword TrimByBottomRight = "bottom-right" // HAlignLeft horizontal align left keyword HAlignLeft = "left" // HAlignRight horizontal align right keyword HAlignRight = "right" // VAlignTop vertical align top keyword VAlignTop = "top" // VAlignBottom vertical align bottom keyword VAlignBottom = "bottom" )
Variables ¶
var DigestResultStorageHasher = ResultStorageHasherFunc(func(p Params) string { if p.Path == "" { p.Path = GeneratePath(p) } return hexDigestPath(p.Path) })
DigestResultStorageHasher ResultStorageHasher using SHA digest
var DigestStorageHasher = StorageHasherFunc(hexDigestPath)
DigestStorageHasher StorageHasher using SHA digest
var SuffixResultStorageHasher = ResultStorageHasherFunc(func(p Params) string { if p.Path == "" { p.Path = GeneratePath(p) } var digest = sha1.Sum([]byte(p.Path)) var hash = "." + hex.EncodeToString(digest[:])[:20] var dotIdx = strings.LastIndex(p.Image, ".") var slashIdx = strings.LastIndex(p.Image, "/") if dotIdx > -1 && slashIdx < dotIdx { ext := p.Image[dotIdx:] if p.Meta { ext = ".json" } else { for _, filter := range p.Filters { if filter.Name == "format" { ext = "." + filter.Args } } } return p.Image[:dotIdx] + hash + ext } return p.Image + hash })
SuffixResultStorageHasher ResultStorageHasher using storage path with digest suffix
Functions ¶
func GeneratePath ¶ added in v0.8.16
GeneratePath generate imagor path by Params struct
func GenerateUnsafe ¶
GenerateUnsafe generate unsafe imagor endpoint by Params struct
Types ¶
type Params ¶
type Params struct { Params bool `json:"-"` Path string `json:"path,omitempty"` Image string `json:"image,omitempty"` Unsafe bool `json:"unsafe,omitempty"` Hash string `json:"hash,omitempty"` Meta bool `json:"meta,omitempty"` Trim bool `json:"trim,omitempty"` TrimBy string `json:"trim_by,omitempty"` TrimTolerance int `json:"trim_tolerance,omitempty"` CropLeft float64 `json:"crop_left,omitempty"` CropTop float64 `json:"crop_top,omitempty"` CropRight float64 `json:"crop_right,omitempty"` CropBottom float64 `json:"crop_bottom,omitempty"` FitIn bool `json:"fit_in,omitempty"` Stretch bool `json:"stretch,omitempty"` Width int `json:"width,omitempty"` Height int `json:"height,omitempty"` PaddingLeft int `json:"padding_left,omitempty"` PaddingTop int `json:"padding_top,omitempty"` PaddingRight int `json:"padding_right,omitempty"` PaddingBottom int `json:"padding_bottom,omitempty"` HFlip bool `json:"h_flip,omitempty"` VFlip bool `json:"v_flip,omitempty"` HAlign string `json:"h_align,omitempty"` VAlign string `json:"v_align,omitempty"` Smart bool `json:"smart,omitempty"` Filters Filters `json:"filters,omitempty"` }
Params image endpoint parameters
type ResultStorageHasher ¶ added in v1.1.0
ResultStorageHasher define key for result storage
type ResultStorageHasherFunc ¶ added in v1.1.0
ResultStorageHasherFunc ResultStorageHasher handler func
func (ResultStorageHasherFunc) HashResult ¶ added in v1.1.0
func (h ResultStorageHasherFunc) HashResult(p Params) string
HashResult implements ResultStorageHasher interface
type SafeChars ¶ added in v0.8.23
type SafeChars interface { // ShouldEscape indicates if char byte should be escaped ShouldEscape(c byte) bool }
SafeChars safe chars for storage paths
func NewSafeChars ¶ added in v0.8.23
NewSafeChars create SafeChars from predefined set of string
type Signer ¶ added in v0.8.23
Signer imagor URL signature signer
func NewDefaultSigner ¶ added in v0.8.23
NewDefaultSigner default signer using SHA1 with secret
type StorageHasher ¶ added in v1.1.0
StorageHasher define image key for storage
type StorageHasherFunc ¶ added in v1.1.0
StorageHasherFunc StorageHasher handler func
func (StorageHasherFunc) Hash ¶ added in v1.1.0
func (h StorageHasherFunc) Hash(image string) string
Hash implements StorageHasher interface