Skip to content

Instantly share code, notes, and snippets.

@chunkhang
Last active March 27, 2020 06:10
Show Gist options
  • Save chunkhang/ba5a0004fb8e8efb83b46c77c8ef262d to your computer and use it in GitHub Desktop.
Save chunkhang/ba5a0004fb8e8efb83b46c77c8ef262d to your computer and use it in GitHub Desktop.
Download placeholder image from picsum.photos
#!/usr/bin/env bash
function show-help() {
echo "usage: picsum <width> [height]"
}
function download-image() {
curl --location "https://picsum.photos/${1}/${2}" --output "$3" 2>/dev/null
echo "$3"
}
if [[ "$#" = 0 ]]; then
show-help
elif [[ "$#" = 1 ]]; then
download-image "$1" "$1" "${RANDOM}-${1}-${1}.jpg"
else
download-image "$1" "$2" "${RANDOM}-${1}-${2}.jpg"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment