@recraft-ai/mcp-recraft-server
Version:
MCP Server implementation for recraft.ai API
27 lines (21 loc) • 620 B
text/typescript
import { rasterizeSvg } from "./render"
export type ImageData = {
data: string
mimeType: string
}
export const imageDataToBlob = async (image: ImageData): Promise<Blob> => {
let { data, mimeType } = image
if (mimeType === 'image/svg+xml') {
const rasterized = await rasterizeSvg(data)
data = rasterized.data
mimeType = rasterized.mimeType
}
const buffer = Buffer.from(data, 'base64')
return new Blob([buffer])
}
export const nn = <T>(value: T | null | undefined): T => {
if (value === null || value === undefined) {
throw new Error("Value is null or undefined")
}
return value
}