Skip to content

Instantly share code, notes, and snippets.

@chadlavi
Created October 16, 2018 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chadlavi/44c0b74fb32d6bb9146fc76d010c5f5d to your computer and use it in GitHub Desktop.
Save chadlavi/44c0b74fb32d6bb9146fc76d010c5f5d to your computer and use it in GitHub Desktop.
a simple script to get an arbitrary number of sample images from unsplash, organized by aspect ratio
#!/bin/sh
mkdir -p example_images/landscape
mkdir -p example_images/portrait
loop=0
iterations=50
while [ $loop -lt $iterations ]; do
x=$(( $RANDOM % 950 + 50 ))
y=$(( $RANDOM % 950 + 50 ))
name="$( echo "scale=2; ${x} / ${y}" | bc )-to-1"
if [[ x -gt y ]]; then
dir="landscape"
else
dir="portrait"
fi
wget http://unsplash.it/${x}/${y} -O ./example_images/${dir}/\(${name}\)_${x}x${y}.jpg
loop=$((loop+1))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment