MCPcopy Create free account
hub / github.com/diillson/chatcli / NormalizeImageMediaType

Function NormalizeImageMediaType

models/image.go:60–69  ·  view source on GitHub ↗

NormalizeImageMediaType lowercases and strips any parameters (e.g. "image/jpeg; charset=binary" -> "image/jpeg") and reports whether the result is a supported image type. Also folds the common "image/jpg" alias onto the canonical "image/jpeg".

(mime string)

Source from the content-addressed store, hash-verified

58// result is a supported image type. Also folds the common "image/jpg"
59// alias onto the canonical "image/jpeg".
60func NormalizeImageMediaType(mime string) (string, bool) {
61 mt := strings.ToLower(strings.TrimSpace(mime))
62 if i := strings.IndexByte(mt, ';'); i >= 0 {
63 mt = strings.TrimSpace(mt[:i])
64 }
65 if mt == "image/jpg" {
66 mt = "image/jpeg"
67 }
68 return mt, supportedImageMediaTypes[mt]
69}
70
71// DetectImageMediaType sniffs the media type from the leading bytes and
72// reports whether it is a supported image. Used when an attachment has

Callers 8

bedrockImageBlocksFunction · 0.92
DataURLFunction · 0.92
anthropicImageBlockFunction · 0.92
GeminiPartsFunction · 0.92
inboundImageToModelsFunction · 0.92
DetectImageMediaTypeFunction · 0.85
IsValidMethod · 0.85

Calls

no outgoing calls

Tested by 1