skip transform if options don't request it

Fixes #64
This commit is contained in:
Will Norris 2016-05-02 19:23:00 -07:00
parent d825852025
commit a71584a63c
3 changed files with 10 additions and 3 deletions

View file

@ -72,8 +72,6 @@ type Options struct {
ScaleUp bool
}
var emptyOptions = Options{}
func (o Options) String() string {
buf := new(bytes.Buffer)
fmt.Fprintf(buf, "%v%s%v", o.Width, optSizeDelimiter, o.Height)
@ -101,6 +99,13 @@ func (o Options) String() string {
return buf.String()
}
// transform returns whether o includes transformation options. Some fields
// are not transform related at all (like Signature), and others only apply in
// the presence of other fields (like Fit and Quality).
func (o Options) transform() bool {
return o.Width != 0 || o.Height != 0 || o.Rotate != 0 || o.FlipHorizontal || o.FlipVertical
}
// ParseOptions parses str as a list of comma separated transformation options.
// The following options can be specified in any order:
//