BashImageGallery

From XPUB & Lens-Based wiki

NB: uses heredocs to include big parts of HTML

# convert images to thumbnails + a webpage
# with thumbnails and fancybox gallery

cat << html > images.html
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>

<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css" />
<script src="https://cdn.jsdelivr.net/gh/fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js"></script>

</head>
<body>
html

mkdir thumbnails
for i in *.png
do
    convert -resize 360x $i thumbnails/$i
    echo "<a data-fancybox=\"gallery\" href=\"$i\"><img src=\"thumbnails/$i\"></a>" >> images.html
done

cat << html >> images.html
</body>
</html>
html