MCPcopy Index your code
hub / github.com/claude-code-best/claude-code / detectImageFormatFromBase64

Function detectImageFormatFromBase64

src/utils/imageResizer.ts:834–844  ·  view source on GitHub ↗
(
  base64Data: string,
)

Source from the content-addressed store, hash-verified

832 * @returns Media type string (e.g., 'image/png', 'image/jpeg') or 'image/png' as default
833 */
834export function detectImageFormatFromBase64(
835 base64Data: string,
836): ImageMediaType {
837 try {
838 const buffer = Buffer.from(base64Data, 'base64')
839 return detectImageFormatFromBuffer(buffer)
840 } catch {
841 // Default to PNG on any error
842 return 'image/png'
843 }
844}
845
846/**
847 * Creates a text description of image metadata including dimensions and source path.

Callers 5

getImageFromClipboardFunction · 0.85
tryReadImageFromPathFunction · 0.85
callFunction · 0.85
normalizeImageBlocksFunction · 0.85

Calls 1

Tested by

no test coverage detected