MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / parseImageTypes

Function parseImageTypes

env/parsers.go:123–137  ·  view source on GitHub ↗

parseImageTypes parses a comma-separated list of image format names and returns a slice of imagetype.Type values.

(env string)

Source from the content-addressed store, hash-verified

121// parseImageTypes parses a comma-separated list of image format names and returns
122// a slice of imagetype.Type values.
123func parseImageTypes(env string) ([]imagetype.Type, error) {
124 parts := strings.Split(env, ",")
125 result := make([]imagetype.Type, 0, len(parts))
126
127 for _, p := range parts {
128 part := strings.TrimSpace(p)
129 t, ok := imagetype.GetTypeByName(part)
130 if !ok {
131 return nil, fmt.Errorf("unknown image format: %s", part)
132 }
133 result = append(result, t)
134 }
135
136 return result, nil
137}
138
139// parseImageTypesQuality parses format=quality pairs (e.g., "jpg=80,webp=90") and returns
140// a map of image types to their quality values (1-100).

Callers

nothing calls this directly

Calls 3

GetTypeByNameFunction · 0.92
SplitMethod · 0.80
ErrorfMethod · 0.80

Tested by

no test coverage detected