Skip to content

Commit a2df905

Browse files
committed
Upload recent talks
1 parent 12988c8 commit a2df905

14 files changed

Lines changed: 247 additions & 76 deletions

_data/preslist.yml

Lines changed: 145 additions & 49 deletions
Large diffs are not rendered by default.

_scripts/pdftogif.sh

Lines changed: 102 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,118 @@
1-
#!/bin/bash -x
1+
#!/usr/bin/env bash
2+
#
3+
# pdftogif.sh
4+
# Convert a multi-page PDF into:
5+
# - an animated GIF (all pages)
6+
# - a PNG preview (first page)
7+
#
8+
# Requires: ghostscript (gs), ImageMagick (convert)
9+
#
10+
# Example:
11+
# ./pdftogif.sh slides.pdf MyPresentation
12+
#
213

3-
if [[ $# -lt 2 ]] ; then
4-
echo 'Please pass the path to the pdf to convert and the name of the output file.'
5-
echo 'Run something like cd images/pubpic; ../../_scripts/pdftogif.sh ../../assets/presentations/B_Kundu-PyHEP23_Cppyy_CppInterOp.pdf BKPyHEPDev2023'
6-
exit 1
7-
fi
14+
set -euo pipefail
15+
16+
# -----------------------
17+
# configuration defaults
18+
# -----------------------
19+
DPI=48
20+
GIF_DELAY=100 # centiseconds (100 = 1s per frame)
21+
22+
# -----------------------
23+
# helpers
24+
# -----------------------
25+
usage() {
26+
cat <<EOF
27+
Usage:
28+
$(basename "$0") <input.pdf> <output_name>
29+
30+
Creates:
31+
<output_name>.gif Animated GIF of all pages
32+
<output_name>.png PNG preview of the first page
33+
34+
Example:
35+
cd images/pubpic
36+
../../_scripts/pdftogif.sh \\
37+
../../assets/presentations/B_Kundu-PyHEP23_Cppyy_CppInterOp.pdf \\
38+
BKPyHEPDev2023
39+
40+
Requirements:
41+
- ghostscript (gs)
42+
- ImageMagick (convert)
43+
EOF
44+
}
845

9-
if ! [ -x "$(command -v gs)" ]; then
10-
echo 'Error: gs is not installed. This script depends on it' >&2
46+
die() {
47+
echo "Error: $*" >&2
1148
exit 1
12-
fi
49+
}
1350

14-
if ! [ -x "$(command -v convert2)" ]; then
15-
echo 'Error: convert is not installed. This script depends on it' >&2
51+
check_cmd() {
52+
command -v "$1" >/dev/null 2>&1 || die "'$1' is not installed or not in PATH"
53+
}
54+
55+
# -----------------------
56+
# argument parsing
57+
# -----------------------
58+
if [[ $# -ne 2 ]]; then
59+
usage
1660
exit 1
1761
fi
1862

19-
SLIDES_PDF=$1
20-
PRES_ID=$2
21-
WORK_DIR=$(mktemp -d)
63+
SLIDES_PDF="$1"
64+
PRES_ID="$2"
65+
66+
[[ -f "$SLIDES_PDF" ]] || die "Input PDF not found: $SLIDES_PDF"
2267

23-
gs -dSAFER -dQUIET -dNOPLATFONTS -dNOPAUSE -dBATCH \
24-
-sOutputFile="$WORK_DIR/%d.png" \
68+
# -----------------------
69+
# dependency checks
70+
# -----------------------
71+
check_cmd gs
72+
check_cmd convert
73+
74+
# -----------------------
75+
# temp working directory
76+
# -----------------------
77+
WORK_DIR="$(mktemp -d "${TMPDIR:-/tmp}/pdftogif.XXXXXX")"
78+
79+
cleanup() {
80+
rm -rf "$WORK_DIR"
81+
}
82+
trap cleanup EXIT
83+
84+
# -----------------------
85+
# PDF → PNGs
86+
# -----------------------
87+
echo "Rendering PDF pages to PNGs…"
88+
89+
gs -dSAFER -dQUIET -dNOPAUSE -dBATCH \
2590
-sDEVICE=pngalpha \
26-
-r48 \
91+
-sOutputFile="$WORK_DIR/%03d.png" \
92+
-r"$DPI" \
2793
-dTextAlphaBits=4 \
2894
-dGraphicsAlphaBits=4 \
2995
-dUseCIEColor \
3096
-dUseTrimBox \
31-
$SLIDES_PDF
97+
"$SLIDES_PDF"
3298

33-
convert -delay 100 $(ls $WORK_DIR/*.png | sort -V) $PRES_ID.gif
34-
mv $WORK_DIR/1.png $PRES_ID.png
99+
# -----------------------
100+
# PNGs → GIF
101+
# -----------------------
102+
echo "Creating animated GIF: ${PRES_ID}.gif"
35103

36-
# deletes the temp directory
37-
function cleanup {
38-
rm -rf "$WORK_DIR"
39-
echo "Deleted temp working directory $WORK_DIR"
40-
}
104+
convert -delay "$GIF_DELAY" \
105+
"$WORK_DIR"/*.png \
106+
"${PRES_ID}.gif"
41107

42-
# register the cleanup function to be called on the EXIT signal
43-
trap cleanup EXIT
108+
# -----------------------
109+
# first page preview
110+
# -----------------------
111+
cp "$WORK_DIR/001.png" "${PRES_ID}.png"
112+
113+
# -----------------------
114+
# done
115+
# -----------------------
116+
echo "Done."
117+
echo "${PRES_ID}.gif"
118+
echo "${PRES_ID}.png"
354 KB
Binary file not shown.
492 KB
Binary file not shown.
240 KB
Binary file not shown.
1.05 MB
Binary file not shown.

images/pubpic/CLADEUROAD2025.gif

236 KB
Loading

images/pubpic/CLADEUROAD2025.png

21.9 KB
Loading
594 KB
Loading
72.1 KB
Loading

0 commit comments

Comments
 (0)