Skip to content

Instantly share code, notes, and snippets.

@huytd
Created August 20, 2025 21:24
Show Gist options
  • Save huytd/431ad9dbef806e96015f8d74d7e65f90 to your computer and use it in GitHub Desktop.
Save huytd/431ad9dbef806e96015f8d74d7e65f90 to your computer and use it in GitHub Desktop.
#!/bin/bash
screencapture -i ~/clipboard.png
IMAGE_BASE64=$(base64 -i ~/clipboard.png | tr -d '\n')
rm ~/clipboard.png
API_KEY="GEMINI_API_KEY_HERE"
MODEL="gemini-2.0-flash"
curl -s -X POST \
-H "Content-Type: application/json" \
-H "X-goog-api-key: ${API_KEY}" \
"https://generativelanguage.googleapis.com/v1beta/models/${MODEL}:generateContent" \
-d "{
\"contents\": [
{
\"parts\": [
{\"text\": \"Extract all the text in this image. Just output the text directly without any quotes, explanation or anything else.\"},
{
\"inline_data\": {
\"mime_type\": \"image/png\",
\"data\": \"${IMAGE_BASE64}\"
}
}
]
}
]
}" | jq -r .candidates[0].content.parts[0].text | pbcopy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment