Commit 33782da6 authored by Juergen Enge's avatar Juergen Enge
Browse files

color parameter

parent d881f624
Pipeline #13798 passed with stages
in 3 minutes and 28 seconds
......@@ -24,9 +24,12 @@ func (iai *ActionImageIIIF) GetType() []string { return []string{"image"} }
var regexpParamImageActionIIIF = []*regexp.Regexp{
regexp.MustCompile("^(size)([0-9]+)x([0-9]+)$"),
regexp.MustCompile("^(rotate)([0-9.]+)$"),
regexp.MustCompile("^(format)(jpeg|png)$"),
regexp.MustCompile("^(color)(|gray|bitonal)?$"),
regexp.MustCompile("^(stretch)$"),
regexp.MustCompile("^(crop)$"),
regexp.MustCompile("^(flip)$"),
}
func (iai *ActionImageIIIF) Do(w http.ResponseWriter, req *http.Request, me *MediaEntry, action string, params ...string) (bool, error) {
......@@ -131,6 +134,25 @@ func (iai *ActionImageIIIF) resize(w http.ResponseWriter, req *http.Request, me
size = "!" + size
}
rotate := "0"
if rot, ok := ps["rotate"]; ok {
rotate = rot[0]
}
if _, ok := ps["flip"]; !ok {
rotate = "!" + rotate
}
color := "default"
if col, ok := ps["color"]; ok {
if len(col) > 0 {
color = col[0]
}
if color == "" {
color = "color"
}
}
resultName := fmt.Sprintf("%s_%vx%v.%s", me.Signature, width, height, ext)
w.Header().Set("Content-Disposition", fmt.Sprintf("filename=\"%s\"", resultName))
......@@ -160,7 +182,7 @@ func (iai *ActionImageIIIF) resize(w http.ResponseWriter, req *http.Request, me
}
// todo: region & rotation parameter
paramstring = fmt.Sprintf("%s/%v/0/default.%s", region, size, ext)
paramstring = fmt.Sprintf("%s/%v/%v/%s.%s", region, size, rotate, color, ext)
sigfile := iai.ms.fspool.Truename(me.URI)
sigfile = strings.TrimPrefix(sigfile, iai.ms.iiifBase)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment