MCPcopy
hub / github.com/codeaashu/claude-code / detectImageFormatFromBase64

Function detectImageFormatFromBase64

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

Source from the content-addressed store, hash-verified

817 * @returns Media type string (e.g., 'image/png', 'image/jpeg') or 'image/png' as default
818 */
819export function detectImageFormatFromBase64(
820 base64Data: string,
821): ImageMediaType {
822 try {
823 const buffer = Buffer.from(base64Data, 'base64')
824 return detectImageFormatFromBuffer(buffer)
825 } catch {
826 // Default to PNG on any error
827 return 'image/png'
828 }
829}
830
831/**
832 * Creates a text description of image metadata including dimensions and source path.

Callers 3

getImageFromClipboardFunction · 0.85
tryReadImageFromPathFunction · 0.85
normalizeImageBlocksFunction · 0.85

Calls 1

Tested by

no test coverage detected