Skip to content

Instantly share code, notes, and snippets.

@dantaeyoung
Last active December 26, 2015 10:30
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 dantaeyoung/1f4eacaf6a8ad0fdbbd2 to your computer and use it in GitHub Desktop.
Save dantaeyoung/1f4eacaf6a8ad0fdbbd2 to your computer and use it in GitHub Desktop.
Create GIF of Instagram User
############## TOTALLY HACKY
############## REQUIRES https://github.com/akurtovic/InstaRaider
############## EDIT $USERNAME AND RUN IT IN PARENT DIRECTORY OF InstaRaider REPO
############## example: ./gifify_instagram_user.sh
#!/bin/bash
USERNAME="alanpaukman"
#milliseconds
GIFDELAY=15
echo "downloading photos..."
mkdir $USERNAME ||
./InstaRaider/instaRaider.py -n 1000 $USERNAME ./$USERNAME &&
echo "resizing photos..."
mkdir ${USERNAME}_captioned
cd ./${USERNAME}
mkdir /tmp/new
find . -iname '*.jpg' |
while read file
do
echo $file
convert -resize '640x640' "$file" /tmp/new/"$file"
touch -r "$file" /tmp/new/"$file"
done
cd ../
cd ./${USERNAME}_captioned
rsync -a /tmp/new/ .
rm -fr /tmp/new
echo "adding timestamp"
## This command will find all image files, if you are using other
## extensions, you can add them: -o "*.foo"
inc=0
for img in `ls -1tr`; do
let inc=inc+1
## Go through the results, saving each as $img
## Find will return full paths, so an image in the current
## directory will be ./foo.jpg and the first dot screws up
## bash's pattern matching. Use basename and dirname to extract
## the needed information.
name=$(basename "$img")
path=$(dirname "$img")
ext="${name/#*./}";
echo $img
date=$(stat -x "$img" | grep Modify | cut -d ' ' -f 2- ) #| cut -d ':' -f1,2)
convert "$img" -gravity SouthEast -font Helvetica -pointsize 16 -fill white \
-annotate +10+10 "$date" \
"$path"/"${USERNAME}-$(printf "%04d" $inc)-${img}";
# "$path"/"${name/%.*/.time.$ext}";
done
echo "creating gif.."
convert -delay $GIFDELAY -loop 0 $(for i in $(ls -1v ${USERNAME}-*); do echo ${i}; done) ../${USERNAME}.gif
cd ..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment