google-image-search

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Google 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
.env
:
Google-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筛选)
  • /opt/homebrew/bin/llm
    路径下安装llm CLI
将凭据存储在
.env
文件中:
Google-Custom-Search-JSON-API-KEY=your_key
Google-Custom-Search-CX=your_cx
OPENROUTER_API_KEY=your_openrouter_key

Modes 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 5

2. 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-select

3. 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.json

4. 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.md
This mode:
  1. Detects Obsidian vault and attachments folder
  2. Uses LLM to extract visual-worthy terms from note
  3. Searches for images for each term
  4. Downloads best images to attachments folder
  5. Inserts image embeds below relevant headings
  6. 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
该模式的具体操作:
  1. 检测Obsidian库和附件文件夹
  2. 使用LLM从笔记中提取适合可视化的术语
  3. 为每个术语搜索图片
  4. 将最优图片下载到附件文件夹
  5. 在相关标题下方插入图片嵌入代码
  6. 修改笔记前创建备份

Key Options

关键选项

OptionDescription
--query TEXT
Simple single query
--config FILE
JSON config for batch
--generate-config
Generate config from
--terms
--enrich-note FILE
Enrich Obsidian note
--output-dir DIR
Where to save images
--urls-only
Return URLs only, no download
--llm-select
Use LLM to pick best image (default: on)
--no-llm-select
Disable LLM selection
--num-results N
Results per query (default: 5)
--dry-run
Show what would be done
选项描述
--query TEXT
简单单个查询
--config FILE
用于批量处理的JSON配置文件
--generate-config
--terms
生成配置
--enrich-note FILE
丰富Obsidian笔记内容
--output-dir DIR
图片保存路径
--urls-only
仅返回URL,不下载图片
--llm-select
使用LLM筛选最优图片(默认开启)
--no-llm-select
禁用LLM筛选
--num-results N
每个查询的返回结果数(默认:5)
--dry-run
显示将要执行的操作(不实际执行)

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
references/api_config_reference.md
for full documentation.
每个条目支持如下格式:
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.md

Scoring 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
    .obsidian
    folder
  • 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

脚本文件

FilePurpose
google_image_search.py
Main entry point
api.py
Google Custom Search API
config.py
Credentials and config handling
download.py
Image download with magic bytes
evaluate.py
Keyword-based scoring
llm_select.py
LLM selection and term extraction
obsidian.py
Vault detection and enrichment
output.py
Markdown output generation
文件用途
google_image_search.py
主入口文件
api.py
Google Custom Search API交互模块
config.py
凭据和配置处理模块
download.py
基于魔术字节的图片下载模块
evaluate.py
基于关键词的评分模块
llm_select.py
LLM筛选和术语提取模块
obsidian.py
库检测和笔记丰富模块
output.py
Markdown输出生成模块