unsplash-image
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseUnsplash Image Search & Download
Unsplash图片搜索与下载
Search Unsplash for images, download them, and optionally add text overlay.
在Unsplash上搜索图片、下载图片,还可选择添加文字覆盖层。
Tool Location
工具位置
- Script:
~/.agents/tools/unsplash-search.py - Env file: (contains
~/.agents/tools/.env)UNSPLASH_CLIENT_ID
- 脚本:
~/.agents/tools/unsplash-search.py - 环境文件:(包含
~/.agents/tools/.env)UNSPLASH_CLIENT_ID
Quick Usage
快速使用
Search and download a random matching image
搜索并下载一张匹配的随机图片
bash
python ~/.agents/tools/unsplash-search.py \
--query "nature landscape" \
--output ./image.jpgbash
python ~/.agents/tools/unsplash-search.py \
--query "nature landscape" \
--output ./image.jpgWith orientation filter
带方向筛选
bash
python ~/.agents/tools/unsplash-search.py \
--query "coffee shop" \
--orientation landscape \
--output ./coffee.jpgbash
python ~/.agents/tools/unsplash-search.py \
--query "coffee shop" \
--orientation landscape \
--output ./coffee.jpgWith text overlay (title and subtitle)
带文字覆盖层(标题和副标题)
bash
python ~/.agents/tools/unsplash-search.py \
--query "technology abstract" \
--output ./cover.png \
--title "My Blog Post Title" \
--subtitle "A short description"bash
python ~/.agents/tools/unsplash-search.py \
--query "technology abstract" \
--output ./cover.png \
--title "My Blog Post Title" \
--subtitle "A short description"List results without downloading
仅列出结果不下载
bash
python ~/.agents/tools/unsplash-search.py \
--query "sunset" \
--listbash
python ~/.agents/tools/unsplash-search.py \
--query "sunset" \
--listPick the first result instead of random
选择第一个结果而非随机
bash
python ~/.agents/tools/unsplash-search.py \
--query "mountains" \
--pick first \
--output ./mountains.jpgbash
python ~/.agents/tools/unsplash-search.py \
--query "mountains" \
--pick first \
--output ./mountains.jpgCLI Options
CLI选项
| Option | Description |
|---|---|
| (Required) Search query string |
| (Required unless --list) Output file path |
| Filter: |
| Color filter (e.g., |
| How to select from results: |
| Title text to overlay on the image |
| Subtitle text to overlay (only used with --title) |
| List search results instead of downloading |
| Number of results to fetch, max 30 (default: 30) |
| 选项 | 描述 |
|---|---|
| (必填) 搜索查询字符串 |
| (使用--list时除外,必填) 输出文件路径 |
| 筛选方向: |
| 颜色筛选(例如: |
| 结果选择方式: |
| 要添加到图片上的标题文字 |
| 副标题文字(仅在使用--title时生效) |
| 列出搜索结果而非下载 |
| 获取的结果数量,最大30(默认:30) |
Text Overlay
文字覆盖层
When is provided, the script adds a text overlay to the bottom portion of the image with:
--title- Semi-transparent dark background behind the text
- White title text with shadow
- Gray subtitle text (if provided)
- Automatic word wrapping and font sizing
Requires Pillow:
pip install Pillow当提供参数时,脚本会在图片底部添加文字覆盖层,包含:
--title- 文字背后的半透明深色背景
- 带阴影的白色标题文字
- 灰色副标题文字(若提供)
- 自动换行和字体大小适配
依赖Pillow:
pip install PillowDependencies
依赖项
- (for API calls and image download)
requests - (only needed if using text overlay with
Pillow)--title
Install if needed:
bash
pip install requests Pillow- (用于API调用和图片下载)
requests - (仅在使用
Pillow添加文字覆盖层时需要)--title
若需安装,执行:
bash
pip install requests PillowOutput
输出
The script prints:
- The download URL
- Photographer attribution (required by Unsplash)
- The saved file path
- Confirmation of text overlay if applied
脚本会打印:
- 下载链接
- 摄影师署名(Unsplash要求必填)
- 文件保存路径
- 若添加了文字覆盖层,会给出确认信息
Notes
注意事项
- Unsplash API guidelines require attribution. The script prints photographer info.
- The script triggers Unsplash's download tracking endpoint as required by their API terms.
- Images are downloaded at "regular" quality (1080px width). For higher resolution, modify the script to use or
urls.full.urls.raw
- Unsplash API指南要求署名,脚本会打印摄影师信息。
- 脚本会触发Unsplash的下载跟踪端点,符合其API条款要求。
- 图片以“常规”质量(宽度1080px)下载。如需更高分辨率,可修改脚本使用或
urls.full。urls.raw