MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / hasImageMacOS

Function hasImageMacOS

cli/src/utils/clipboard-image.ts:43–66  ·  view source on GitHub ↗

* Check if clipboard contains an image (macOS) * Uses 'clipboard info' which is the fastest way to check clipboard types. * * Note: We do NOT filter out clipboards that contain file URLs here, because * copying images from Finder/Preview/Safari often includes both a file URL * AND the actual i

()

Source from the content-addressed store, hash-verified

41 * checked first via clipboard text, then we fall back to image data).
42 */
43function hasImageMacOS(): boolean {
44 try {
45 const result = spawnSync('osascript', [
46 '-e',
47 'clipboard info',
48 ], { encoding: 'utf-8', timeout: 1000 })
49
50 if (result.status !== 0) {
51 return false
52 }
53
54 const output = result.stdout || ''
55
56 // Check for image types in clipboard info
57 return output.includes('«class PNGf»') ||
58 output.includes('TIFF') ||
59 output.includes('«class JPEG»') ||
60 output.includes('public.png') ||
61 output.includes('public.tiff') ||
62 output.includes('public.jpeg')
63 } catch {
64 return false
65 }
66}
67
68/**
69 * Read image from clipboard (macOS)

Callers 1

hasClipboardImageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected