-
-
Save sahal/b3d1e4fa82e91ca650521f96f9b72383 to your computer and use it in GitHub Desktop.
Generate Thumbnail-Index with ImageMagick
This file contains hidden or 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 | |
| file_extension="${1:-png}" | |
| > index.html | |
| [ -d thumbs ] || mkdir thumbs | |
| echo "Generating Thumbnails..." | |
| for f in *.${file_extension}; do | |
| magick convert "${f%.*}.${file_extension}" -strip -thumbnail 200x100 "thumbs/${f%.*}.png" &> /dev/null | |
| done | |
| thumbnail_filenames="$(find ./thumbs/ -maxdepth 1 -name \*.png |sort -n)" | |
| echo "Generating Index..." | |
| for thumb in ${thumbnail_filenames}; do | |
| filename="${thumb%.*}" | |
| filename_of_thumbnail="./thumbs/${filename##*/}.png" | |
| filename_of_large_file="./${filename##*/}.${file_extension}" | |
| cat << EOF | |
| <a href="$filename_of_large_file"> | |
| <img src="$filename_of_thumbnail" border="0" | |
| style="margin:10px;border:1px solid #ccc;"> | |
| </a> | |
| EOF | |
| done >> index.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment