feat: ADD EXIF striping #3
This commit is contained in:
parent
9c91e77e9f
commit
be696c343c
3 changed files with 69 additions and 3 deletions
|
|
@ -2,6 +2,11 @@ FROM docker.io/ubuntu:24.04
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# exiftool: strips EXIF/GPS metadata from published images (see build.sh)
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends libimage-exiftool-perl \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Copy project files
|
# Copy project files
|
||||||
COPY build.sh /app/
|
COPY build.sh /app/
|
||||||
COPY templates /app/templates
|
COPY templates /app/templates
|
||||||
|
|
|
||||||
31
README.md
31
README.md
|
|
@ -12,7 +12,8 @@ Simple SSG to create dynamic gallery one-pagers in your shell! Shell+Gallery
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
**Available**:
|
**Available**:
|
||||||
- Simple use without dependencies
|
- Simple use, single dependency (exiftool)
|
||||||
|
- Removes EXIF/GPS metadata from published images by default
|
||||||
- no Javascript
|
- no Javascript
|
||||||
- Lightbox of image with anchor
|
- Lightbox of image with anchor
|
||||||
- Order of images via filename
|
- Order of images via filename
|
||||||
|
|
@ -21,7 +22,6 @@ Simple SSG to create dynamic gallery one-pagers in your shell! Shell+Gallery
|
||||||
|
|
||||||
**Ideas**:
|
**Ideas**:
|
||||||
- check file formats
|
- check file formats
|
||||||
- remove exif data
|
|
||||||
- conf file for options
|
- conf file for options
|
||||||
- anonymize file names
|
- anonymize file names
|
||||||
- sections via file names
|
- sections via file names
|
||||||
|
|
@ -30,6 +30,17 @@ Simple SSG to create dynamic gallery one-pagers in your shell! Shell+Gallery
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- `bash` and GNU coreutils
|
||||||
|
- [`exiftool`](https://exiftool.org/) - `apt install libimage-exiftool-perl` (Debian/Ubuntu) or `brew install exiftool` (macOS)
|
||||||
|
|
||||||
|
Docker/Podman users need nothing on the host, exiftool is baked into the image.
|
||||||
|
|
||||||
|
Building with `--keep-exif` / `STRIP_EXIF=0` does not require exiftool.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
### Docker / Podman
|
### Docker / Podman
|
||||||
|
|
@ -59,6 +70,22 @@ docker run -v $(pwd)/images:/app/images -v $(pwd)/output:/app/output localhost/s
|
||||||
|
|
||||||
The generated gallery will be in `./output/index.html`
|
The generated gallery will be in `./output/index.html`
|
||||||
|
|
||||||
|
### Metadata removal
|
||||||
|
|
||||||
|
EXIF, GPS, IPTC and XMP metadata is stripped from every image by default. Only the copies
|
||||||
|
in `./output/` are processed, your originals in `./images/` are never modified.
|
||||||
|
|
||||||
|
To publish images with their metadata intact:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./build.sh --keep-exif
|
||||||
|
# or
|
||||||
|
STRIP_EXIF=0 ./build.sh
|
||||||
|
|
||||||
|
# container
|
||||||
|
podman run -e STRIP_EXIF=0 -v $(pwd)/images:/app/images -v $(pwd)/output:/app/output git.uphillsecurity.com/cf7/shellery:latest
|
||||||
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
|
||||||
36
build.sh
36
build.sh
|
|
@ -10,6 +10,29 @@ OUTPUT_DIR="output"
|
||||||
TEMPLATES_DIR="templates"
|
TEMPLATES_DIR="templates"
|
||||||
ASSETS_DIR="assets"
|
ASSETS_DIR="assets"
|
||||||
|
|
||||||
|
# Image metadata (EXIF/GPS/IPTC/XMP) is stripped by default.
|
||||||
|
# Opt out with STRIP_EXIF=0 or --keep-exif.
|
||||||
|
STRIP_EXIF="${STRIP_EXIF:-1}"
|
||||||
|
|
||||||
|
for arg in "$@"; do
|
||||||
|
case "$arg" in
|
||||||
|
--keep-exif) STRIP_EXIF=0 ;;
|
||||||
|
-h|--help)
|
||||||
|
echo "usage: ./build.sh [--keep-exif]"
|
||||||
|
echo " --keep-exif do not strip image metadata (env: STRIP_EXIF=0)"
|
||||||
|
exit 0 ;;
|
||||||
|
*) echo "unknown option: $arg" >&2; exit 1 ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# Fail before writing any output if the default cannot be honoured
|
||||||
|
if [[ "$STRIP_EXIF" == "1" ]] && ! command -v exiftool >/dev/null 2>&1; then
|
||||||
|
echo "error: exiftool is required to strip image metadata." >&2
|
||||||
|
echo " install: apt install libimage-exiftool-perl (or: brew install exiftool)" >&2
|
||||||
|
echo " bypass: STRIP_EXIF=0 ./build.sh or ./build.sh --keep-exif" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Create output directory
|
# Create output directory
|
||||||
mkdir -p "$OUTPUT_DIR"
|
mkdir -p "$OUTPUT_DIR"
|
||||||
|
|
||||||
|
|
@ -57,7 +80,18 @@ done
|
||||||
# Copy assets
|
# Copy assets
|
||||||
cp -r "$ASSETS_DIR"/* "$OUTPUT_DIR/"
|
cp -r "$ASSETS_DIR"/* "$OUTPUT_DIR/"
|
||||||
|
|
||||||
# Copy images
|
# Copy images, then strip metadata from the copies (originals are never touched)
|
||||||
cp -r "$IMAGES_DIR" "$OUTPUT_DIR/"
|
cp -r "$IMAGES_DIR" "$OUTPUT_DIR/"
|
||||||
|
|
||||||
|
if [[ "$STRIP_EXIF" == "1" ]]; then
|
||||||
|
if compgen -G "$OUTPUT_DIR/$IMAGES_DIR/*" > /dev/null; then
|
||||||
|
if ! exiftool -all= -overwrite_original -q -q "$OUTPUT_DIR/$IMAGES_DIR"; then
|
||||||
|
echo "error: exiftool failed; output images may still contain metadata" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "warning: EXIF stripping disabled, image metadata will be published as-is" >&2
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Gallery generated successfully in $OUTPUT_DIR/index.html"
|
echo "Gallery generated successfully in $OUTPUT_DIR/index.html"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue