• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

cshum / imagor / 15327829984

29 May 2025 03:46PM UTC coverage: 92.318% (-0.09%) from 92.412%
15327829984

Pull #550

github

cshum
WithForceBmpFallback WithForceBufferFallback
Pull Request #550: feat: fallback with BMP or Buffer on Magick installation

56 of 75 new or added lines in 3 files covered. (74.67%)

1 existing line in 1 file now uncovered.

4879 of 5285 relevant lines covered (92.32%)

1.11 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.65
/processor/vipsprocessor/option.go
1
package vipsprocessor
2

3
import (
4
        "go.uber.org/zap"
5
        "strings"
6
)
7

8
// Option Processor option
9
type Option func(v *Processor)
10

11
// WithFilter with filer option of name and FilterFunc pair
12
func WithFilter(name string, filter FilterFunc) Option {
1✔
13
        return func(v *Processor) {
2✔
14
                v.Filters[name] = filter
1✔
15
        }
1✔
16
}
17

18
// WithDisableBlur with disable blur option
19
func WithDisableBlur(disabled bool) Option {
1✔
20
        return func(v *Processor) {
2✔
21
                v.DisableBlur = disabled
1✔
22
        }
1✔
23
}
24

25
// WithDisableFilters with disable filters option
26
func WithDisableFilters(filters ...string) Option {
1✔
27
        return func(v *Processor) {
2✔
28
                for _, raw := range filters {
2✔
29
                        splits := strings.Split(raw, ",")
1✔
30
                        for _, name := range splits {
2✔
31
                                name = strings.TrimSpace(name)
1✔
32
                                if len(name) > 0 {
2✔
33
                                        v.DisableFilters = append(v.DisableFilters, name)
1✔
34
                                }
1✔
35
                        }
36
                }
37
        }
38
}
39

40
// WithMozJPEG with MozJPEG option. Require MozJPEG to be installed
41
func WithMozJPEG(enabled bool) Option {
1✔
42
        return func(v *Processor) {
2✔
43
                v.MozJPEG = enabled
1✔
44
        }
1✔
45
}
46

47
// WithStripMetadata with strip all metadata from image option
48
func WithStripMetadata(enabled bool) Option {
1✔
49
        return func(v *Processor) {
2✔
50
                v.StripMetadata = enabled
1✔
51
        }
1✔
52
}
53

54
// WithAvifSpeed with avif speed option
55
func WithAvifSpeed(avifSpeed int) Option {
1✔
56
        return func(v *Processor) {
2✔
57
                if avifSpeed >= 0 && avifSpeed <= 9 {
2✔
58
                        v.AvifSpeed = avifSpeed
1✔
59
                }
1✔
60
        }
61
}
62

63
// WithMaxFilterOps with maximum number of filter operations option
64
func WithMaxFilterOps(num int) Option {
1✔
65
        return func(v *Processor) {
2✔
66
                if num != 0 {
2✔
67
                        v.MaxFilterOps = num
1✔
68
                }
1✔
69
        }
70
}
71

72
// WithMaxAnimationFrames with maximum count of animation frames option
73
func WithMaxAnimationFrames(num int) Option {
1✔
74
        return func(v *Processor) {
2✔
75
                if num != 0 {
2✔
76
                        v.MaxAnimationFrames = num
1✔
77
                }
1✔
78
        }
79
}
80

81
// WithConcurrency with libvips concurrency option
82
func WithConcurrency(num int) Option {
1✔
83
        return func(v *Processor) {
2✔
84
                if num != 0 {
2✔
85
                        v.Concurrency = num
1✔
86
                }
1✔
87
        }
88
}
89

90
// WithMaxCacheFiles with libvips max cache files option
91
func WithMaxCacheFiles(num int) Option {
1✔
92
        return func(v *Processor) {
2✔
93
                if num > 0 {
2✔
94
                        v.MaxCacheFiles = num
1✔
95
                }
1✔
96
        }
97
}
98

99
// WithMaxCacheSize with libvips max cache size option
100
func WithMaxCacheSize(num int) Option {
1✔
101
        return func(v *Processor) {
2✔
102
                if num > 0 {
2✔
103
                        v.MaxCacheSize = num
1✔
104
                }
1✔
105
        }
106
}
107

108
// WithMaxCacheMem with libvips max cache mem option
109
func WithMaxCacheMem(num int) Option {
1✔
110
        return func(v *Processor) {
2✔
111
                if num > 0 {
2✔
112
                        v.MaxCacheMem = num
1✔
113
                }
1✔
114
        }
115
}
116

117
// WithLogger with logger option
118
func WithLogger(logger *zap.Logger) Option {
1✔
119
        return func(v *Processor) {
2✔
120
                if logger != nil {
2✔
121
                        v.Logger = logger
1✔
122
                }
1✔
123
        }
124
}
125

126
// WithDebug with debug option
127
func WithDebug(debug bool) Option {
1✔
128
        return func(v *Processor) {
2✔
129
                v.Debug = debug
1✔
130
        }
1✔
131
}
132

133
// WithMaxWidth with maximum width option
134
func WithMaxWidth(width int) Option {
1✔
135
        return func(v *Processor) {
2✔
136
                if width > 0 {
2✔
137
                        v.MaxWidth = width
1✔
138
                }
1✔
139
        }
140
}
141

142
// WithMaxHeight with maximum height option
143
func WithMaxHeight(height int) Option {
1✔
144
        return func(v *Processor) {
2✔
145
                if height > 0 {
2✔
146
                        v.MaxHeight = height
1✔
147
                }
1✔
148
        }
149
}
150

151
// WithMaxResolution with maximum resolution option
152
func WithMaxResolution(res int) Option {
1✔
153
        return func(v *Processor) {
2✔
154
                if res > 0 {
2✔
155
                        v.MaxResolution = res
1✔
156
                }
1✔
157
        }
158
}
159

160
// WithForceBmpFallback force with BMP fallback
161
func WithForceBmpFallback() Option {
1✔
162
        return func(v *Processor) {
2✔
163
                v.FallbackFunc = BmpFallbackFunc
1✔
164
        }
1✔
165
}
166

167
// WithForceBufferFallback force with buffer fallback
NEW
168
func WithForceBufferFallback() Option {
×
NEW
169
        return func(v *Processor) {
×
NEW
170
                v.FallbackFunc = BufferFallbackFunc
×
NEW
171
        }
×
172
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc