chore: outils preview, mesure, design system et Dockerfile
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
# Dockerfile — conteneur sliding-preview · Chantier C2
|
||||
# PPTX → PDF → PNG par slide, sur GrosseBertha (ARM64, DSM 7.3.2).
|
||||
# Polices : Carlito/Caladea (métriquement compatibles Calibri/Cambria)
|
||||
# installées dans l'image ; les TTF PR réelles peuvent être montées en
|
||||
# volume sur /fonts (prioritaires, voir preview_inner.sh).
|
||||
#
|
||||
# Build (dossier docker/preview/, single-line) :
|
||||
# docker build -t sliding-preview .
|
||||
|
||||
FROM ubuntu:24.04
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
libreoffice-impress \
|
||||
poppler-utils \
|
||||
fontconfig \
|
||||
fonts-crosextra-carlito \
|
||||
fonts-crosextra-caladea \
|
||||
fonts-liberation \
|
||||
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY preview_inner.sh /usr/local/bin/preview_inner.sh
|
||||
RUN chmod +x /usr/local/bin/preview_inner.sh
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/preview_inner.sh"]
|
||||
@@ -0,0 +1,68 @@
|
||||
#!/bin/sh
|
||||
# preview_inner.sh — exécuté DANS le conteneur sliding-preview · Chantier C2
|
||||
# Usage : preview_inner.sh /work/chemin/deck.pptx [dpi]
|
||||
# Produit : <dossier du pptx>/<nom>_previews/slide-NN.png + index.html
|
||||
set -e
|
||||
|
||||
PPTX="$1"
|
||||
DPI="${2:-110}"
|
||||
|
||||
if [ -z "$PPTX" ] || [ ! -f "$PPTX" ]; then
|
||||
echo "preview_inner: fichier introuvable: $PPTX" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Polices PR réelles montées en volume (prioritaires sur Carlito/Caladea)
|
||||
if [ -d /fonts ]; then
|
||||
mkdir -p /usr/local/share/fonts/custom
|
||||
cp -f /fonts/*.ttf /fonts/*.TTF /fonts/*.otf \
|
||||
/usr/local/share/fonts/custom/ 2>/dev/null || true
|
||||
fc-cache -f >/dev/null 2>&1 || true
|
||||
fi
|
||||
|
||||
BASE=$(basename "$PPTX" .pptx)
|
||||
DIR=$(dirname "$PPTX")
|
||||
OUT="$DIR/${BASE}_previews"
|
||||
TMP=/tmp/lo
|
||||
mkdir -p "$OUT" "$TMP"
|
||||
rm -f "$OUT"/slide-*.png "$OUT/index.html"
|
||||
|
||||
# 1. PPTX → PDF (profil LibreOffice jetable : pas de lock, RAM contenue)
|
||||
echo "preview_inner: conversion PDF ($BASE)..."
|
||||
soffice --headless --norestore \
|
||||
-env:UserInstallation=file:///tmp/louser \
|
||||
--convert-to pdf --outdir "$TMP" "$PPTX" >/dev/null
|
||||
|
||||
PDF="$TMP/$BASE.pdf"
|
||||
if [ ! -f "$PDF" ]; then
|
||||
echo "preview_inner: la conversion PDF a échoué." >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# 2. PDF → PNG par page
|
||||
echo "preview_inner: rasterisation PNG (${DPI} dpi)..."
|
||||
pdftoppm -png -r "$DPI" "$PDF" "$OUT/slide"
|
||||
|
||||
# 3. Normalisation slide-N.png → slide-0N.png (decks < 10 slides)
|
||||
for f in "$OUT"/slide-?.png; do
|
||||
[ -f "$f" ] || continue
|
||||
n=$(basename "$f")
|
||||
mv "$f" "$OUT/slide-0${n#slide-}"
|
||||
done
|
||||
|
||||
# 4. Galerie index.html (consultable via File Station ou partage web)
|
||||
{
|
||||
printf '%s\n' '<!doctype html><html><head><meta charset="utf-8">'
|
||||
printf '<title>%s</title>\n' "$BASE"
|
||||
printf '%s\n' '<style>body{font-family:Calibri,Carlito,sans-serif;background:#F4F1EC;margin:20px;color:#2B3440}h1{color:#061033;font-size:22px}div.g{display:grid;grid-template-columns:repeat(auto-fill,minmax(320px,1fr));gap:14px}figure{margin:0;background:#fff;padding:8px;border-radius:6px;box-shadow:0 1px 4px rgba(6,16,51,.15)}img{width:100%;display:block}figcaption{text-align:center;color:#46505A;font-size:13px;padding-top:6px}</style></head><body>'
|
||||
printf '<h1>%s</h1><div class=g>\n' "$BASE"
|
||||
for f in "$OUT"/slide-*.png; do
|
||||
n=$(basename "$f")
|
||||
printf '<figure><img src="%s" loading="lazy"><figcaption>%s</figcaption></figure>\n' "$n" "$n"
|
||||
done
|
||||
printf '%s\n' '</div></body></html>'
|
||||
} > "$OUT/index.html"
|
||||
|
||||
rm -f "$PDF"
|
||||
NB=$(ls "$OUT"/slide-*.png 2>/dev/null | wc -l | tr -d ' ')
|
||||
echo "preview_inner: $NB slides -> $OUT"
|
||||
Reference in New Issue
Block a user