@just-every/ensemble
Version:
LLM provider abstraction layer with unified streaming interface
31 lines • 930 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.isValidBase64 = isValidBase64;
exports.detectImageType = detectImageType;
function isValidBase64(str) {
try {
return btoa(atob(str)) === str;
}
catch {
return false;
}
}
function detectImageType(base64Data) {
try {
const decoded = atob(base64Data.slice(0, 16));
const bytes = new Uint8Array(decoded.split('').map(char => char.charCodeAt(0)));
if (bytes[0] === 0xff && bytes[1] === 0xd8)
return 'image/jpeg';
if (bytes[0] === 0x89 && bytes[1] === 0x50)
return 'image/png';
if (bytes[0] === 0x47 && bytes[1] === 0x49)
return 'image/gif';
if (bytes[0] === 0x52 && bytes[1] === 0x49)
return 'image/webp';
return null;
}
catch {
return null;
}
}
//# sourceMappingURL=image_validation.js.map
;