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

Function DetectImageMediaType

models/image.go:74–79  ·  view source on GitHub ↗

DetectImageMediaType sniffs the media type from the leading bytes and reports whether it is a supported image. Used when an attachment has no declared MIME (local file read, raw paste).

(data []byte)

Source from the content-addressed store, hash-verified

72// reports whether it is a supported image. Used when an attachment has
73// no declared MIME (local file read, raw paste).
74func DetectImageMediaType(data []byte) (string, bool) {
75 if len(data) == 0 {
76 return "", false
77 }
78 return NormalizeImageMediaType(http.DetectContentType(data))
79}
80
81// IsValid reports whether the image carries usable bytes (Data or URL)
82// and a supported media type.

Callers 5

loadFirstGeneratedImageFunction · 0.92
inboundImageToModelsFunction · 0.92
loadImageAttachmentMethod · 0.92
loadInputImagesFunction · 0.92
TestDetectImageMediaTypeFunction · 0.85

Calls 1

NormalizeImageMediaTypeFunction · 0.85

Tested by 1

TestDetectImageMediaTypeFunction · 0.68