(buf: Buffer, claimed: string)
| 63 | } |
| 64 | |
| 65 | function 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 | |
| 75 | interface PreparedVisionImage { |
| 76 | buffer: Buffer |
no outgoing calls
no test coverage detected