Last active
October 19, 2017 05:52
-
-
Save dgtlmoon/511896db20c7adb18830743bc04db443 to your computer and use it in GitHub Desktop.
build a full blueimp based file image based on files in current directory
This file contains 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/bash | |
echo -n "Enter gallery name: " | |
read galname | |
which parallel &>/dev/null | |
if [ $? -ne 0 ] | |
then | |
echo "apt-get install parallel before you can continue" | |
exit | |
fi | |
echo "Cloning blueimp gallery" | |
git clone https://github.com/blueimp/Gallery.git /tmp/Gallery &>/dev/null | |
if [ ! -f /tmp/Gallery/README.md ] | |
then | |
echo "Did not find gallery :(" | |
exit | |
fi | |
mkdir -p web/js web/css | |
cp -r /tmp/Gallery/js/* web/js/ | |
cp -r /tmp/Gallery/css/* web/css/ | |
echo "$galname" > web/info.txt | |
# Very lazy script for grabbing your images and building some pages to view them | |
> joblist.txt | |
> dirs.txt | |
for i in *JPG; do | |
d=`ls -al "$i"|awk '{print $6 $7}'` | |
echo "web/$d" >> dirs.txt | |
echo "web/$d/thumbnails" >> dirs.txt | |
# build the jobs to run with parallel | |
echo "convert -scale 2048x \"$i\" web/$d/\"$i\"" >> joblist.txt | |
echo "convert -scale 150x \"$i\" web/$d/thumbnails/\"$i\"" >> joblist.txt | |
done | |
echo "Creating directories" | |
cat dirs.txt|sort|uniq|while read subdirname | |
do | |
mkdir -p $subdirname | |
done | |
echo "Creating templates in directories" | |
cat dirs.txt|grep -v thumbnail|sort|uniq|while read subdirname | |
do | |
curl https://gist.githubusercontent.com/dgtlmoon/b945832352989753e87dec47638f4467/raw/e4ef290d38e88c10a81c7de4680c0d66a0fc943d/index.php -o $subdirname/index.php &>/dev/null | |
done | |
echo "Running converter to build images" | |
cat joblist.txt |parallel --shuf -j 6 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment