Startup implements imagor.Processor interface
(ctx context.Context)
| 126 | |
| 127 | // Startup implements imagor.Processor interface |
| 128 | func (v *Processor) Startup(ctx context.Context) error { |
| 129 | processorLock.Lock() |
| 130 | defer processorLock.Unlock() |
| 131 | processorCount++ |
| 132 | if processorCount <= 1 { |
| 133 | if v.Debug { |
| 134 | vips.SetLogging(func(domain string, level vips.LogLevel, msg string) { |
| 135 | switch level { |
| 136 | case vips.LogLevelDebug: |
| 137 | v.Logger.Debug(domain, zap.String("log", msg)) |
| 138 | case vips.LogLevelMessage, vips.LogLevelInfo: |
| 139 | v.Logger.Info(domain, zap.String("log", msg)) |
| 140 | case vips.LogLevelWarning, vips.LogLevelCritical, vips.LogLevelError: |
| 141 | v.Logger.Warn(domain, zap.String("log", msg)) |
| 142 | } |
| 143 | }, vips.LogLevelDebug) |
| 144 | } else { |
| 145 | vips.SetLogging(func(domain string, level vips.LogLevel, msg string) { |
| 146 | v.Logger.Warn(domain, zap.String("log", msg)) |
| 147 | }, vips.LogLevelError) |
| 148 | } |
| 149 | vips.Startup(&vips.Config{ |
| 150 | MaxCacheFiles: v.MaxCacheFiles, |
| 151 | MaxCacheMem: v.MaxCacheMem, |
| 152 | MaxCacheSize: v.MaxCacheSize, |
| 153 | ConcurrencyLevel: v.Concurrency, |
| 154 | VectorDisableTargets: v.VectorDisableTargets, |
| 155 | }) |
| 156 | } |
| 157 | v.hasDcrawload = vips.HasOperation("dcrawload_source") |
| 158 | if v.hasDcrawload { |
| 159 | v.Logger.Debug("dcrawload support enabled") |
| 160 | } |
| 161 | if v.FallbackFunc == nil { |
| 162 | if vips.HasOperation("magickload_buffer") { |
| 163 | v.FallbackFunc = bufferFallbackFunc |
| 164 | v.Logger.Debug("source fallback", zap.String("fallback", "magickload_buffer")) |
| 165 | } else { |
| 166 | v.FallbackFunc = v.bmpFallbackFunc |
| 167 | v.Logger.Debug("source fallback", zap.String("fallback", "bmp")) |
| 168 | } |
| 169 | } |
| 170 | if v.CacheSize > 0 && v.cache == nil { |
| 171 | cache, err := newImageCache(v.CacheSize) |
| 172 | if err != nil { |
| 173 | return err |
| 174 | } |
| 175 | v.cache = cache |
| 176 | } |
| 177 | for _, d := range v.Detectors { |
| 178 | if err := d.Startup(ctx); err != nil { |
| 179 | return fmt.Errorf("detector startup: %w", err) |
| 180 | } |
| 181 | } |
| 182 | return nil |
| 183 | } |
| 184 | |
| 185 | // AddDetector implements imagor.DetectorAdder. |