From 3279719cfe3613e32b2c24550f02b4f06c0c2347 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Fri, 20 Oct 2023 00:32:58 +0200 Subject: [PATCH] feat(run): add `thumbnails:generate` task --- .gitignore | 3 ++- flake.nix | 1 + run | 27 ++++++++++++++++++++++++--- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index cb76843..85ecc7c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,8 @@ # rst2df. /**/*.pdf /**/*.rst.build_temp -/dist/*.pdf +/dist/* +!/dist/.keep # pdfpc. /**/*.pdfpc diff --git a/flake.nix b/flake.nix index dbfdc33..404da1a 100644 --- a/flake.nix +++ b/flake.nix @@ -13,6 +13,7 @@ devshells.default = { packages = with pkgs; [ + ghostscript pdfpc python310Packages.rst2pdf tree diff --git a/run b/run index 34831b4..35f4317 100755 --- a/run +++ b/run @@ -48,9 +48,30 @@ function pdf:present { pdfpc "${@}" "dist/${TALK_PATH}.pdf" --switch-screens } -function thumbnail:generate { - # Generate a thumbnail image of the first slide in the presentation. - echo "TODO: thumbnail:generate" +# Generate JPG thumbnails of each slide in a presentation. +function thumbnails:generate { + if [ "${1}" == "" ]; then + echo "Usage: ./${0##*/} ${FUNCNAME[0]} " + exit 1 + fi + + if [ ! -d "src/${1}" ]; then + echo "${1} not found" + exit 2 + fi + + pdf:generate "${1}" + + mkdir -p "dist/${1}" + + gs \ + -dBATCH \ + -dDownScaleFactor=3 \ + -dNOPAUSE \ + -r600 \ + -sDEVICE=jpeg \ + -sOutputFile="dist/${1}/%d.jpg" \ + "dist/${1}.pdf" } TIMEFORMAT=$'\nTask completed in %3lR'