Created
November 19, 2019 20:20
-
-
Save jakebathman/45ea8d4a50f18b9030e7c067724dd532 to your computer and use it in GitHub Desktop.
Get three placeholder images of set sizes, with random filenames
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Set a few variables | |
SIZE_M=(750 422) | |
SIZE_T=(1536 864) | |
SIZE_D=(2780 1564) | |
BASE="https://picsum.photos" | |
# Move to the download folder | |
cd ~/Downloads | |
# Get the first image, to see what the redirect is (so all images match) | |
IMG_URL=$(curl -Ls -o /dev/null -w %{url_effective} "https://picsum.photos/${SIZE_M[0]}/${SIZE_M[1]}") | |
ENDPARAMS=${IMG_URL##*/id/} | |
IMG_ID=${ENDPARAMS%%/*} | |
BASE="${BASE}/id/${IMG_ID}" | |
MOBILE="${BASE}/${SIZE_M[0]}/${SIZE_M[1]}" | |
TABLET="${BASE}/${SIZE_T[0]}/${SIZE_T[1]}" | |
DESKTOP="${BASE}/${SIZE_D[0]}/${SIZE_D[1]}" | |
# Fetch each of the files | |
PREFIX=$(cat /dev/urandom | env LC_CTYPE=C tr -dc 'a-z0-9' | fold -w 8 | head -n 1) | |
printf "." && wget -q -O "${PREFIX}_${SIZE_D[0]}x${SIZE_D[1]}.jpg" "$DESKTOP" | |
sleep 0.2 | |
printf "." && wget -q -O "${PREFIX}_${SIZE_T[0]}x${SIZE_T[1]}.jpg" "$TABLET" | |
sleep 0.2 | |
printf "." && wget -q -O "${PREFIX}_${SIZE_M[0]}x${SIZE_M[1]}.jpg" "$MOBILE" | |
echo "done!" | |
ls -lsa ~/Downloads | grep -o -e "${PREFIX}.*" --color=none |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment