google-image-search
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGoogle Image Search Skill
Google图片搜索Skill
Search for images using Google Custom Search API with intelligent scoring and LLM-based selection.
借助LLM驱动的筛选功能,通过Google Custom Search API搜索图片。
When to Use
适用场景
- Finding images to illustrate technical articles or research
- Adding visuals to presentations
- Enriching Obsidian notes with relevant images
- Batch image search for multiple topics
- Generating image search configs from plain text lists
- 为技术文章或研究寻找配图
- 为演示文稿添加视觉素材
- 为Obsidian笔记添加相关图片
- 针对多个主题批量搜索图片
- 从纯文本列表生成图片搜索配置
Requirements
必要条件
- Google Custom Search API key and Search Engine ID
- OpenRouter API key (for LLM selection)
- llm CLI installed at
/opt/homebrew/bin/llm
Store credentials in :
.envGoogle-Custom-Search-JSON-API-KEY=your_key
Google-Custom-Search-CX=your_cx
OPENROUTER_API_KEY=your_openrouter_key- Google Custom Search API密钥和搜索引擎ID
- OpenRouter API密钥(用于LLM筛选)
- 在路径下安装llm CLI
/opt/homebrew/bin/llm
将凭据存储在文件中:
.envGoogle-Custom-Search-JSON-API-KEY=your_key
Google-Custom-Search-CX=your_cx
OPENROUTER_API_KEY=your_openrouter_keyModes of Operation
操作模式
1. Simple Query
1. 简单查询
Search for a single term:
bash
python3 ~/.claude/skills/google-image-search/scripts/google_image_search.py \
--query "neural interface wearable device" \
--output-dir ./images \
--num-results 5搜索单个术语:
bash
python3 ~/.claude/skills/google-image-search/scripts/google_image_search.py \
--query "neural interface wearable device" \
--output-dir ./images \
--num-results 52. Batch Processing
2. 批量处理
Process multiple queries from JSON config:
bash
python3 ~/.claude/skills/google-image-search/scripts/google_image_search.py \
--config image_queries.json \
--output-dir ./images \
--llm-select通过JSON配置处理多个查询:
bash
python3 ~/.claude/skills/google-image-search/scripts/google_image_search.py \
--config image_queries.json \
--output-dir ./images \
--llm-select3. Generate Config from Terms
3. 从术语生成配置
Create JSON config from a list of terms using LLM:
bash
python3 ~/.claude/skills/google-image-search/scripts/google_image_search.py \
--generate-config \
--terms "AlterEgo wearable" "sEMG electrodes" "BCI headset" \
--output my_queries.json使用LLM从术语列表创建JSON配置:
bash
python3 ~/.claude/skills/google-image-search/scripts/google_image_search.py \
--generate-config \
--terms "AlterEgo wearable" "sEMG electrodes" "BCI headset" \
--output my_queries.json4. Enrich Obsidian Note
4. 丰富Obsidian笔记
Extract visual terms from note, find images, and insert below headings:
bash
python3 ~/.claude/skills/google-image-search/scripts/google_image_search.py \
--enrich-note ~/Brains/brain/Research/neural-interfaces.mdThis mode:
- Detects Obsidian vault and attachments folder
- Uses LLM to extract visual-worthy terms from note
- Searches for images for each term
- Downloads best images to attachments folder
- Inserts image embeds below relevant headings
- Creates backup before modifying note
从笔记中提取需可视化的术语,查找图片并插入到标题下方:
bash
python3 ~/.claude/skills/google-image-search/scripts/google_image_search.py \
--enrich-note ~/Brains/brain/Research/neural-interfaces.md该模式的具体操作:
- 检测Obsidian库和附件文件夹
- 使用LLM从笔记中提取适合可视化的术语
- 为每个术语搜索图片
- 将最优图片下载到附件文件夹
- 在相关标题下方插入图片嵌入代码
- 修改笔记前创建备份
Key Options
关键选项
| Option | Description |
|---|---|
| Simple single query |
| JSON config for batch |
| Generate config from |
| Enrich Obsidian note |
| Where to save images |
| Return URLs only, no download |
| Use LLM to pick best image (default: on) |
| Disable LLM selection |
| Results per query (default: 5) |
| Show what would be done |
| 选项 | 描述 |
|---|---|
| 简单单个查询 |
| 用于批量处理的JSON配置文件 |
| 从 |
| 丰富Obsidian笔记内容 |
| 图片保存路径 |
| 仅返回URL,不下载图片 |
| 使用LLM筛选最优图片(默认开启) |
| 禁用LLM筛选 |
| 每个查询的返回结果数(默认:5) |
| 显示将要执行的操作(不实际执行) |
JSON Config Format
JSON配置格式
Each entry supports:
json
{
"id": "unique-id",
"heading": "Display Heading",
"description": "Context for what image to find",
"query": "Google search query",
"numResults": 5,
"selectionCriteria": "What makes a good image",
"requiredTerms": ["must", "have"],
"optionalTerms": ["bonus", "terms"],
"excludeTerms": ["stock", "clipart"],
"preferredHosts": ["official-site.com"],
"selectionCount": 2
}See for full documentation.
references/api_config_reference.md每个条目支持如下格式:
json
{
"id": "unique-id",
"heading": "Display Heading",
"description": "Context for what image to find",
"query": "Google search query",
"numResults": 5,
"selectionCriteria": "What makes a good image",
"requiredTerms": ["must", "have"],
"optionalTerms": ["bonus", "terms"],
"excludeTerms": ["stock", "clipart"],
"preferredHosts": ["official-site.com"],
"selectionCount": 2
}完整文档请查看。
references/api_config_reference.mdScoring System
评分系统
Images are scored based on:
- Required terms: -80 if missing, +30 if all present
- Optional terms: +5 per match
- Exclude terms: -50 per match
- Preferred hosts: +25 if trusted, -5 if unknown
- MIME type: +5 for PNG/JPEG, -10 for GIF
- Resolution: +10 for high res, -10 for low res
- File size: -5 if very small
图片评分基于以下维度:
- 必填术语:缺失则扣80分,全部存在则加30分
- 可选术语:每匹配一个加5分
- 排除术语:每匹配一个扣50分
- 优先主机:来自可信主机加25分,未知主机扣5分
- MIME类型:PNG/JPEG格式加5分,GIF格式扣10分
- 分辨率:高分辨率加10分,低分辨率扣10分
- 文件大小:文件过小扣5分
LLM Selection
LLM筛选
After scoring, LLM picks the best image from top candidates based on:
- Title and URL metadata
- Scoring reasons
- Selection criteria
The LLM evaluates authenticity, clarity, and relevance for technical audiences.
评分完成后,LLM会根据以下标准从候选图片中挑选最优图片:
- 标题和URL元数据
- 评分依据
- 筛选条件
LLM会针对技术受众评估图片的真实性、清晰度和相关性。
Obsidian Integration
Obsidian集成
When in an Obsidian vault:
- Auto-detects vault root via folder
.obsidian - Uses configured attachments folder (default: )
Attachments - Generates Obsidian-style embeds:
![[image.png|alt text]] - Creates backup before modifying notes
在Obsidian库中使用时:
- 通过文件夹自动检测库根目录
.obsidian - 使用已配置的附件文件夹(默认:)
Attachments - 生成Obsidian风格的嵌入代码:
![[image.png|alt text]] - 修改笔记前创建备份
Script Files
脚本文件
| File | Purpose |
|---|---|
| Main entry point |
| Google Custom Search API |
| Credentials and config handling |
| Image download with magic bytes |
| Keyword-based scoring |
| LLM selection and term extraction |
| Vault detection and enrichment |
| Markdown output generation |
| 文件 | 用途 |
|---|---|
| 主入口文件 |
| Google Custom Search API交互模块 |
| 凭据和配置处理模块 |
| 基于魔术字节的图片下载模块 |
| 基于关键词的评分模块 |
| LLM筛选和术语提取模块 |
| 库检测和笔记丰富模块 |
| Markdown输出生成模块 |