惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Engineering at Meta
Engineering at Meta
Microsoft Azure Blog
Microsoft Azure Blog
I
InfoQ
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
人人都是产品经理
人人都是产品经理
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Tailwind CSS Blog
MongoDB | Blog
MongoDB | Blog
Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
量子位
美团技术团队
大猫的无限游戏
大猫的无限游戏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Last Week in AI
Last Week in AI
博客园 - 司徒正美
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
小众软件
小众软件
C
Check Point Blog
博客园 - 三生石上(FineUI控件)
N
Netflix TechBlog - Medium
Recent Announcements
Recent Announcements
有赞技术团队
有赞技术团队
月光博客
月光博客

Danb Blog

August 2026: What I've Been Working On · Danb Blog Great Tech: Intel 2500k CPU · Danb Blog July 2026: What I've Been Working On · Danb Blog My Experience with Ubuntu Desktop 26.04 · Danb Blog Thumbnails for Orca 3MF in GNOME Files · Danb Blog Cheaper Sodastream Gas with a Big Tank · Danb Blog June 2026: What I've Been Working On · Danb Blog Running Snyk On Forgejo/Codeberg Actions · Danb Blog Tuta & Proton: An Open Source Client Does Not Result in an Open Source Service · Danb Blog May 2026: What I've Been Working On · Danb Blog 3D Printing Parts for my Greenhouse, Round 2 · Danb Blog Great Devices: Nexus 7 2013 · Danb Blog R36S Console RetroArch Stuck Menu Issue · Danb Blog April 2026: What I've Been Working On · Danb Blog Basic OpenCode Sandboxing with Docker · Danb Blog Games Played in 2025 · Danb Blog March 2026: What I've Been Working On · Danb Blog Shivam Mathur's "node-docker" Images are Awesome for PHP CI · Danb Blog February 2026: What I've Been Working On · Danb Blog Your BookStackApp project was assigned as a project for my Software Architecture course · Danb Blog My Sovol SV08 3D Printer Setup in 2026 · Danb Blog January 2026: What I've Been Working On · Danb Blog Epson Printer: The administrator password you entered was not recognized · Danb Blog Pressure to Follow Process · Danb Blog Online Shopping Email Notifications · Danb Blog My HomeLab Setup in 2026 · Danb Blog Linux Label Printing with the Phomemo D30 · Danb Blog Reporting to the CMA: Google Android Developer Verification · Danb Blog OPNsense & Dnsmasq: Responding with specific DNS servers · Danb Blog An Impromptu Introduction to ZFS Drive Replacement at 1am · Danb Blog
Quickly Getting Placeholder Images With Unsplash Source ·...
2021-04-19 · via Danb Blog

I often find myself needing a batch of placeholder images when testing or creating dummy content within projects. Unsplash is a great source for these but downloading each image and making them a reasonable size can take time. They do offer an API but it’s highly limited without creating an account and, even then, getting random images will still take multiple requests.

Fortunately, they offer Unsplash Source. This allows easy direct links to images with the idea you can directly use unsplash source images in online projects. This also provides a very simple API to get random images. A request to https://source.unsplash.com/random/400x200?cat will redirect to a 400px wide by 200px high random picture of cat.

Building a Script

The below is a simple bash script uses unsplash source to get $COUNT many (Where $COUNT is the first argument passed when the script is called) images from unsplash. A second/third/fourth argument, for width/height/topic respectively, can be passed. A delay is added between image fetches to decrease the chances of duplicate images appearing.

#!/bin/bash

# Argument Variables
COUNT=$1
WIDTH=${2:-"1200"}
HEIGHT=${3:-"600"}
TOPIC=${4:-""}

# Show help when now arguments are passed
if [ -z "$COUNT" ]
then
    echo "--- unsplash-get ---"
    echo "Usage:   unsplash-get <count> [width=1200] [height=600] [topic]"
    echo "Example: unsplash-get 50"
    echo "Example: unsplash-get 5 250 250 cats"
    echo "--------------------"
    exit 0;
fi

# Adjust filename to include topic if provided
PREFIX="${TOPIC}_"
if [ -z "$TOPIC" ]
then
    PREFIX=""
fi

# Get our images
for i in $(seq 1 $COUNT)
do
    echo "Fetching image ${i} of ${COUNT}"
    curl -sL "https://source.unsplash.com/random/${WIDTH}x${HEIGHT}?${TOPIC}" > "${PREFIX}image_${WIDTH}x${HEIGHT}_$i.jpg"
    sleep 0.6
done