MCPcopy Index your code
hub / github.com/simstudioai/sim / detectImageMime

Function detectImageMime

apps/sim/lib/copilot/vfs/file-reader.ts:65–73  ·  view source on GitHub ↗
(buf: Buffer, claimed: string)

Source from the content-addressed store, hash-verified

63}
64
65function detectImageMime(buf: Buffer, claimed: string): string {
66 if (buf.length < 12) return claimed
67 if (buf[0] === 0xff && buf[1] === 0xd8 && buf[2] === 0xff) return 'image/jpeg'
68 if (buf[0] === 0x89 && buf[1] === 0x50 && buf[2] === 0x4e && buf[3] === 0x47) return 'image/png'
69 if (buf[0] === 0x47 && buf[1] === 0x49 && buf[2] === 0x46) return 'image/gif'
70 if (buf[8] === 0x57 && buf[9] === 0x45 && buf[10] === 0x42 && buf[11] === 0x50)
71 return 'image/webp'
72 return claimed
73}
74
75interface PreparedVisionImage {
76 buffer: Buffer

Callers 1

prepareImageForVisionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected