logo

scripts

A bunch of scripts, some to be moved to their own repository git clone https://hacktivis.me/git/scripts.git

script.sh (2214B)


  1. #!/bin/sh
  2. # Copyright 2017-2020 CC-BY-SA-4.0 Haelwenn (lanodan) Monnier <contact@hacktivis.me>
  3. # Script that generates a photo gallery with details on dedicated pages
  4. ## Generate the index
  5. test -e index.html || (
  6. title=$(basename "${PWD}")
  7. echo "<!DOCTYPE html>
  8. <html>
  9. <head>
  10. <meta charset=\"utf-8\"/>
  11. <title>${title} — AFKs of lanodan</title>
  12. <link rel=\"stylesheet\" href=\"../style.css\" />
  13. </head>
  14. <body>
  15. <h1>${title}</h1>
  16. <main>"
  17. for img in *.JPG; do
  18. test -e "./thumbs/$img" || gm convert "$img" -resize 8% -auto-orient -quality 69% "./thumbs/$img" && jpegoptim -s "./thumbs/$img"
  19. echo "<a class=\"photo\" href=\"${img//.JPG/.html}\"><img loading=\"lazy\" "$(gm identify -format 'width="%[width]" height="%[height]"' "./thumbs/$img")" src=\"thumbs/$img\"/></a>";
  20. done
  21. echo " </main>
  22. <footer rel=\"copyright\">© 2014-2020 <a rel=\"license\" href=\"http://creativecommons.org/licenses/by-sa/4.0/\">CC-BY-SA-4.0</a> Haelwenn (lanodan) Monnier</footer>
  23. </body>
  24. </html>" ) | tee index.html
  25. ## Generate pages for images (with EXIF data)
  26. for img in *.JPG; do
  27. test -e "${img//.JPG/.html}" || (
  28. echo "<!DOCTYPE html>
  29. <html>
  30. <head>
  31. <meta charset=\"utf-8\"/>
  32. <title>$(basename "${PWD}")/${img//.JPG} — AFKs of lanodan</title>
  33. <link rel=\"stylesheet\" href=\"../style.css\" />
  34. </head>
  35. <body>
  36. <h1><a href=\"./\">$(basename "${PWD}")</a>/${img//.JPG}</h1>
  37. <main>"
  38. test -e "./preview/$img" || gm convert "$img" -resize 50% -auto-orient -quality 80% "./preview/$img"
  39. gm identify "$img" -format '<a class="photo" href="$img"><img width="%[width]" height="%[height]" src="preview/$img"/></a>
  40. <ul>
  41. <li>Camera: %[EXIF:Make]%[EXIF:Model]'
  42. printf ' <li>DateTime: '; date "+%F %T%z" --date="$(gm identify "$img" -format '%[EXIF:DateTime]'|sed -r 's/:(..):/-\1-/')Z"
  43. gm identify "$img" -format ' <li>ExposureTime: %[EXIF:ExposureTime]
  44. <li>ISOSpeedRatings: %[EXIF:ISOSpeedRatings]
  45. <li>FNumber: %[EXIF:FNumber]
  46. <li>MaxApertureValue: %[EXIF:MaxApertureValue]
  47. <li rel=\"copyright\">© 2014-2020 <a rel=\"license\" href=\"http://creativecommons.org/licenses/by-sa/4.0/\">CC-BY-SA-4.0</a> Haelwenn (lanodan) Monnier</li>
  48. </ul>'
  49. echo " </main>
  50. </body>
  51. </html>") | tee "${img//.JPG/.html}"
  52. done