Skip to content

Instantly share code, notes, and snippets.

@hilem
Created January 29, 2014 06:17
Show Gist options
  • Save hilem/8682824 to your computer and use it in GitHub Desktop.
Save hilem/8682824 to your computer and use it in GitHub Desktop.
post images to a directory, set this script to watch the directory with cron
#!/bin/bash
# A simple script to create an album artwork montage
## move files to within montage directory w/ prepended unix timestamp
c_time=$(date +%s)
for f in `ls /tmp | grep "now_playing-"`
do
mv /tmp/${f} /tmp/montage/${c_time}_${f}
c_time=$(($c_time + 1))
done
## sort by last modified date, and remove all but the most recent 15 images
count=1
for f in `ls -r /tmp/montage`
do
if [ $count -gt 15 ]
then
rm /tmp/montage/$f
fi
count=$(($count + 1))
done
## create montage image
montage -mode concatenate -tile 3x /tmp/montage/* /tmp/montage_result.jpg
cp /tmp/montage_result.jpg /var/www/ghost/content/themes/sticko/assets/images/sidebar_bg.jpg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment