mirror of
https://github.com/willnorris/imageproxy.git
synced 2025-03-11 02:19:14 -05:00
use strings.Join to construct options string
This commit is contained in:
parent
a85bfef357
commit
fb63cbe9df
1 changed files with 10 additions and 12 deletions
22
data.go
22
data.go
|
@ -15,7 +15,6 @@
|
||||||
package imageproxy
|
package imageproxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
@ -79,33 +78,32 @@ type Options struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o Options) String() string {
|
func (o Options) String() string {
|
||||||
buf := new(bytes.Buffer)
|
opts := []string{fmt.Sprintf("%v%s%v", o.Width, optSizeDelimiter, o.Height)}
|
||||||
fmt.Fprintf(buf, "%v%s%v", o.Width, optSizeDelimiter, o.Height)
|
|
||||||
if o.Fit {
|
if o.Fit {
|
||||||
fmt.Fprintf(buf, ",%s", optFit)
|
opts = append(opts, optFit)
|
||||||
}
|
}
|
||||||
if o.Rotate != 0 {
|
if o.Rotate != 0 {
|
||||||
fmt.Fprintf(buf, ",%s%d", string(optRotatePrefix), o.Rotate)
|
opts = append(opts, fmt.Sprintf("%s%d", string(optRotatePrefix), o.Rotate))
|
||||||
}
|
}
|
||||||
if o.FlipVertical {
|
if o.FlipVertical {
|
||||||
fmt.Fprintf(buf, ",%s", optFlipVertical)
|
opts = append(opts, optFlipVertical)
|
||||||
}
|
}
|
||||||
if o.FlipHorizontal {
|
if o.FlipHorizontal {
|
||||||
fmt.Fprintf(buf, ",%s", optFlipHorizontal)
|
opts = append(opts, optFlipHorizontal)
|
||||||
}
|
}
|
||||||
if o.Quality != 0 {
|
if o.Quality != 0 {
|
||||||
fmt.Fprintf(buf, ",%s%d", string(optQualityPrefix), o.Quality)
|
opts = append(opts, fmt.Sprintf("%s%d", string(optQualityPrefix), o.Quality))
|
||||||
}
|
}
|
||||||
if o.Signature != "" {
|
if o.Signature != "" {
|
||||||
fmt.Fprintf(buf, ",%s%s", string(optSignaturePrefix), o.Signature)
|
opts = append(opts, fmt.Sprintf("%s%s", string(optSignaturePrefix), o.Signature))
|
||||||
}
|
}
|
||||||
if o.ScaleUp {
|
if o.ScaleUp {
|
||||||
fmt.Fprintf(buf, ",%s", optScaleUp)
|
opts = append(opts, optScaleUp)
|
||||||
}
|
}
|
||||||
if o.Format != "" {
|
if o.Format != "" {
|
||||||
fmt.Fprintf(buf, ",%s", o.Format)
|
opts = append(opts, o.Format)
|
||||||
}
|
}
|
||||||
return buf.String()
|
return strings.Join(opts, ",")
|
||||||
}
|
}
|
||||||
|
|
||||||
// transform returns whether o includes transformation options. Some fields
|
// transform returns whether o includes transformation options. Some fields
|
||||||
|
|
Loading…
Add table
Reference in a new issue