37 Commits
Author SHA1 Message Date
instameex-ci 31eb812f09 Bump build version to 1.1.8 [skip ci] 2026-11-28 04:20:43 +00:00
Boteex Bot 0889443933 Merge pull request 'Pin dependencies' (#17) from renovate/weekly-maintenance into main
CI / build-and-scan (push) Successful in 1m0s
2026-11-28 05:11:53 +01:00
Boteex Bot 917d8c6ebd Pin dependencies
renovate/stability-days Updates have met minimum release age requirement
CI / build-and-scan (pull_request) Successful in 2m31s
2026-11-28 04:03:57 +00:00
instameex-ci 05107b21bc Bump build version to 1.1.7 [skip ci] 2026-11-24 23:27:47 +00:00
Djeex b1ba0fb582 Merge pull request 'Update python Docker tag to v3.15.2' (#16) from renovate/python-3.x into main
CI / build-and-scan (push) Successful in 54s
Reviewed-on: #16
2026-11-24 23:59:28 +01:00
Boteex Bot 24c45a928c Update python Docker tag to v3.15.2
renovate/stability-days Updates have met minimum release age requirement
CI / build-and-scan (pull_request) Successful in 48s
2026-11-24 22:23:48 +00:00
Djeex 0f76a3aa0a Use the shared cicdeex actions (#15)
CI / build-and-scan (push) Successful in 1m5s
Co-authored-by: Djeex <[email protected]>
2026-11-22 13:35:08 +01:00
Djeex ec24e591f6 Merge pull request 'Run the weekly scan on Saturday' (#14) from ci-align into main
CI / build-and-scan (push) Successful in 40s
2026-11-21 23:48:48 +01:00
Djeex 572922791c Run the weekly scan on Saturday
CI / build-and-scan (pull_request) Successful in 2m38s
2026-11-21 22:31:35 +00:00
Djeex e79e2d9b86 Merge pull request 'Use the shared Renovate preset' (#12) from renovate-preset into main
CI / build-and-scan (push) Successful in 42s
2026-11-21 22:18:32 +01:00
Djeex 4ae6a71afc Use the shared Renovate preset
CI / build-and-scan (pull_request) Successful in 58s
2026-11-21 20:56:56 +00:00
instameex-ci aa7fd7c3fb Bump build version to 1.1.6 [skip ci] 2026-11-21 19:50:13 +00:00
Djeex 43e843a82b Merge pull request 'Update dependency gunicorn to v27' (#11) from renovate/gunicorn-27.x into main
CI / build-and-scan (push) Successful in 53s
Reviewed-on: #11
2026-11-21 20:49:33 +01:00
Djeex d264ce6762 Merge remote-tracking branch 'origin/main' into gunicorn-no-ctl
CI / build-and-scan (pull_request) Successful in 1m33s
2026-11-21 19:42:57 +00:00
Djeex 094a71df0f Disable the gunicorn control socket 2026-11-21 19:40:28 +00:00
instameex-ci d2e9b9afd4 Bump build version to 1.1.5 [skip ci] 2026-11-21 19:20:43 +00:00
Djeex 707ffef786 Merge pull request 'Update dependency tifffile to v2026.11.12' (#8) from renovate/tifffile-2026.x into main
CI / build-and-scan (push) Successful in 1m20s
2026-11-21 20:14:39 +01:00
Djeex d720aa4b1d Update dependency gunicorn to v27
renovate/stability-days Updates have met minimum release age requirement
CI / build-and-scan (pull_request) Successful in 1m52s
2026-11-21 19:09:42 +00:00
Djeex 99b3024671 Update dependency tifffile to v2026.11.12
renovate/stability-days Updates have met minimum release age requirement
CI / build-and-scan (pull_request) Successful in 4m5s
2026-11-21 19:09:41 +00:00
instameex-ci 2594dacdcf Bump build version to 1.1.4 [skip ci] 2026-11-21 19:06:49 +00:00
Djeex 554de3f041 Merge pull request 'Update dependency numpy to v2.5.4' (#7) from renovate/numpy-2.x into main
CI / build-and-scan (push) Successful in 1m42s
2026-11-21 20:05:32 +01:00
instameex-ci fc16ed0e89 Bump build version to 1.1.3 [skip ci] 2026-11-21 19:03:37 +00:00
Djeex d9b03108de Merge branch 'main' into renovate/numpy-2.x
CI / build-and-scan (pull_request) Successful in 1m31s
2026-11-21 20:02:46 +01:00
Djeex f8dd834419 Merge pull request 'Upgrade Python to 3.14.10' (#10) from python-upgrade into main
CI / build-and-scan (push) Successful in 1m18s
Reviewed-on: #10
2026-11-21 20:02:35 +01:00
Djeex b494404088 Merge remote-tracking branch 'origin/main' into python-upgrade
CI / build-and-scan (pull_request) Successful in 2m7s
2026-11-21 18:52:32 +00:00
Djeex 6fa5b0e333 Upgrade Python to 3.14.10 2026-11-21 18:49:44 +00:00
Djeex 548ccc0dbe Merge pull request 'Do not pin digests for CI tool images' (#9) from fix-pin-regex into main
CI / build-and-scan (push) Successful in 2m39s
Reviewed-on: #9
2026-11-21 19:45:57 +01:00
Djeex a4e3e36249 Do not pin digests for CI tool images
CI / build-and-scan (pull_request) Successful in 1m48s
2026-11-21 18:26:51 +00:00
Djeex 82792375a2 Update dependency numpy to v2.5.4
renovate/stability-days Updates have met minimum release age requirement
CI / build-and-scan (pull_request) Failing after 10s
2026-11-21 18:18:33 +00:00
instameex-ci 6d810b76cf Bump build version to 1.1.2 [skip ci] 2026-11-21 17:53:41 +00:00
Djeex 7378de15ec Merge pull request 'Pin base images and add end-to-end tests' (#6) from ci-cd into main
CI / build-and-scan (push) Successful in 1m50s
Reviewed-on: #6
2026-11-21 18:46:29 +01:00
Djeex 93d448140e Merge remote-tracking branch 'origin/main' into ci-cd
CI / build-and-scan (pull_request) Successful in 1m23s
# Conflicts:
#	docker/Dockerfile
2026-11-21 17:28:45 +00:00
Djeex 8e4378539d Merge pull request 'Update aquasec/trivy Docker tag to v0.76.2' (#4) from renovate/aquasec-trivy-0.x into main
CI / build-and-scan (push) Successful in 33s
Reviewed-on: #4
2026-11-21 18:28:05 +01:00
Djeex 5233594685 Merge pull request 'Update alpine Docker tag to v3.24' (#3) from renovate/alpine-3.x into main
CI / build-and-scan (push) Failing after 39s
Reviewed-on: #3
2026-11-21 18:27:51 +01:00
Djeex 657dfdef6b Pin base images and add end-to-end tests
CI / build-and-scan (pull_request) Successful in 4m54s
2026-11-21 17:25:48 +00:00
Djeex 9300430550 Update aquasec/trivy Docker tag to v0.76.2
CI / build-and-scan (pull_request) Successful in 48s
2026-11-21 16:58:51 +00:00
Djeex 8c4afd98d9 Update alpine Docker tag to v3.24
CI / build-and-scan (pull_request) Successful in 1m59s
2026-11-21 16:58:48 +00:00
7 changed files with 140 additions and 258 deletions

No files matched your search

+46 -210
View File
@@ -6,7 +6,8 @@ on:
pull_request:
branches: [main]
schedule:
- cron: "0 6 * * 1"
# Saturday 05:00 UTC: 06:00 in Paris in winter, 07:00 in summer (Gitea runs cron in UTC).
- cron: "0 5 * * 6"
jobs:
build-and-scan:
@@ -18,19 +19,22 @@ jobs:
fetch-depth: 0
persist-credentials: false
- name: Get shared actions
uses: actions/checkout@v7
with:
repository: labeex/cicdeex
ref: 1.1.0
token: ${{ secrets.CICDEEX_TOKEN }}
path: .cicdeex
persist-credentials: false
- name: Scan for secrets
run: |
# docker cp, not a build COPY: a repo's own .dockerignore would otherwise
# silently give an empty, falsely-clean scan.
CID=$(docker create zricethezav/gitleaks:v8.30.1 detect --source=/repo --no-banner -v)
docker cp . "$CID:/repo"
docker start -a "$CID"
STATUS=$?
docker rm "$CID" > /dev/null
exit $STATUS
uses: ./.cicdeex/secret-scan
- name: Lint Dockerfile with hadolint
run: docker run --rm -i hadolint/hadolint:v2.15.1-alpine hadolint --failure-threshold error - < docker/Dockerfile
uses: ./.cicdeex/hadolint
with:
dockerfile: docker/Dockerfile
- name: Build Docker image
run: |
@@ -62,211 +66,43 @@ jobs:
- name: Scan with Trivy (critical - blocking)
id: trivy_critical
continue-on-error: true
run: |
docker run --rm \
-e DOCKER_HOST=tcp://dockerhost:2375 \
--add-host=dockerhost:host-gateway \
aquasec/trivy:0.74.0 image --exit-code 1 --severity CRITICAL instameex:ci
uses: ./.cicdeex/trivy
with:
image: instameex:ci
- name: Handle CRITICAL findings
if: steps.trivy_critical.outcome == 'failure'
run: |
if [ "${{ github.event_name }}" != "schedule" ]; then
echo "::error::CRITICAL vulnerabilities found, failing the build."
exit 1
fi
echo "Scheduled scan found CRITICAL vulnerabilities — attempting an automatic apk upgrade + rescan."
# Add an apk upgrade right after the base stage's FROM
sed -i '/^FROM python:.* AS base$/a RUN apk upgrade --no-cache' docker/Dockerfile
docker build -f docker/Dockerfile -t instameex:remediated .
if docker run --rm \
-e DOCKER_HOST=tcp://dockerhost:2375 \
--add-host=dockerhost:host-gateway \
aquasec/trivy:0.74.0 image --exit-code 1 --severity CRITICAL instameex:remediated; then
echo "apk upgrade clears the CRITICAL finding(s) — opening a PR for review."
BRANCH="auto/cve-fix-$(date +%Y%m%d)-$(echo "${{ github.sha }}" | cut -c1-7)"
git config user.name "instameex-ci"
git config user.email "[email protected]"
git checkout -b "$BRANCH"
git add docker/Dockerfile
git commit -m "Auto-remediate CRITICAL CVE via apk upgrade"
git config --unset-all http.https://git.djeex.fr/.extraheader || true
git push "https://Djeex:${{ secrets.CI_PUSH_TOKEN }}@git.djeex.fr/Djeex/instameex.git" "HEAD:$BRANCH"
PR_JSON=$(curl -s -X POST \
-H "Authorization: token ${{ secrets.CI_PUSH_TOKEN }}" \
-H "Content-Type: application/json" \
-d "$(jq -n --arg head "$BRANCH" '{title: "🔒 Auto: remediate CRITICAL CVE via apk upgrade", head: $head, base: "main", body: "Opened automatically by the scheduled CVE scan. An `apk upgrade --no-cache` cleared the CRITICAL Trivy finding(s) in a rebuild — review the diff and merge to publish the fix."}')" \
"https://git.djeex.fr/api/v1/repos/Djeex/instameex/pulls")
echo "PR API response: $(echo "$PR_JSON" | jq -r '.html_url // .message // "unknown"')"
else
echo "::error::apk upgrade does not clear the CRITICAL finding(s) — no automatic fix available, needs manual review."
exit 1
fi
uses: ./.cicdeex/remediate
with:
push-token: ${{ secrets.CI_PUSH_TOKEN }}
dockerfile: docker/Dockerfile
from-pattern: "^FROM python:.* AS base$"
- name: Scan with Trivy (high - informative)
run: |
docker run --rm \
-e DOCKER_HOST=tcp://dockerhost:2375 \
--add-host=dockerhost:host-gateway \
aquasec/trivy:0.74.0 image --exit-code 0 --severity HIGH instameex:ci
uses: ./.cicdeex/trivy
with:
image: instameex:ci
severity: HIGH
exit-code: "0"
- name: Publish tagged image
id: publish
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
BEFORE="${{ github.event.before }}"
if [ -n "$BEFORE" ] && [ "$BEFORE" != "0000000000000000000000000000000000000000" ] && git cat-file -e "$BEFORE" 2>/dev/null; then
BASE_REF="$BEFORE"
else
BASE_REF="HEAD~1"
fi
CHANGED=$(git diff --name-only "$BASE_REF" "${{ github.sha }}")
echo "Changed files:"
echo "$CHANGED"
uses: ./.cicdeex/publish
with:
image: instameex:ci
paths: '^(VERSION|main\.py|requirements\.txt)$|^(docker|src)/'
push-token: ${{ secrets.CI_PUSH_TOKEN }}
registry-token: ${{ secrets.REGISTRY_TOKEN }}
github-mirror: "true"
github-token: ${{ secrets.GH_TOKEN }}
release-banner: |-
> [!NOTE]
>⚠️ _This is an heavily vibe-coded proof of concept — do not expose it to the internet — use it at your own risk._
if ! echo "$CHANGED" | grep -qE '^(VERSION|main\.py|requirements\.txt)$|^(docker|src)/'; then
echo "No container-relevant file changed, skipping publish."
exit 0
fi
if echo "$CHANGED" | grep -qE '^VERSION$'; then
echo "VERSION was manually edited in this push, using it as-is."
else
echo "VERSION untouched but container files changed, auto-bumping the build number (Z)."
OLD_VERSION=$(tr -d '[:space:]' < VERSION)
IFS='.' read -r MAJOR MINOR PATCH <<< "$OLD_VERSION"
NEW_VERSION="${MAJOR}.${MINOR}.$((PATCH + 1))"
echo "$NEW_VERSION" > VERSION
git config user.name "instameex-ci"
git config user.email "[email protected]"
git add VERSION
git commit -m "Bump build version to $NEW_VERSION [skip ci]"
git config --unset-all http.https://git.djeex.fr/.extraheader || true
git push "https://Djeex:${{ secrets.CI_PUSH_TOKEN }}@git.djeex.fr/Djeex/instameex.git" HEAD:main
fi
VERSION=$(tr -d '[:space:]' < VERSION)
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
MINOR_TAG="${MAJOR}.${MINOR}"
IMAGE=git.djeex.fr/djeex/instameex
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login git.djeex.fr -u Djeex --password-stdin
# Retag the already-built, already-scanned image — never rebuild for publish,
# so what ships is byte-for-byte what Trivy just scanned.
docker tag instameex:ci "$IMAGE:latest"
docker tag instameex:ci "$IMAGE:$MINOR_TAG"
docker tag instameex:ci "$IMAGE:$VERSION"
docker push "$IMAGE:latest"
docker push "$IMAGE:$MINOR_TAG"
docker push "$IMAGE:$VERSION"
GHCR_IMAGE=ghcr.io/djeex/instameex
echo "${{ secrets.GH_TOKEN }}" | docker login ghcr.io -u Djeex --password-stdin
docker tag instameex:ci "$GHCR_IMAGE:latest"
docker tag instameex:ci "$GHCR_IMAGE:$MINOR_TAG"
docker tag instameex:ci "$GHCR_IMAGE:$VERSION"
docker push "$GHCR_IMAGE:latest"
docker push "$GHCR_IMAGE:$MINOR_TAG"
docker push "$GHCR_IMAGE:$VERSION"
TRIGGER_MSG=$(git log -1 --format=%s "${{ github.sha }}")
PR_NUM=$(echo "$TRIGGER_MSG" | grep -oE '#[0-9]+' | head -1 | tr -d '#' || true)
CATEGORY="🔧 Maintenance"
CHANGE_TITLE="$TRIGGER_MSG"
if [ -n "$PR_NUM" ]; then
PR_JSON=$(curl -s -H "Authorization: token ${{ secrets.CI_PUSH_TOKEN }}" \
"https://git.djeex.fr/api/v1/repos/Djeex/instameex/pulls/$PR_NUM")
PR_TITLE=$(echo "$PR_JSON" | jq -r '.title // empty' 2>/dev/null || true)
LABELS=$(echo "$PR_JSON" | jq -r '.labels[]?.name' 2>/dev/null || true)
if [ -n "$PR_TITLE" ]; then
CHANGE_TITLE="$PR_TITLE"
fi
if echo "$LABELS" | grep -qx 'bug'; then
CATEGORY="⚠️ Hotfix"
elif echo "$LABELS" | grep -qx 'major'; then
CATEGORY="💥 Breaking change"
elif echo "$LABELS" | grep -qx 'minor'; then
CATEGORY="✨ Update"
fi
fi
REPO_URL="https://git.djeex.fr/Djeex/instameex"
COMMIT_LIST=$(git log --no-merges --format="- %s ([%h](${REPO_URL}/commit/%H))" "$BASE_REF".."${{ github.sha }}")
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
SOURCE_LINE="[${SHORT_SHA}](${REPO_URL}/commit/${{ github.sha }})"
if [ -n "$PR_NUM" ]; then
SOURCE_LINE="[#${PR_NUM}](${REPO_URL}/pulls/${PR_NUM}) · ${SOURCE_LINE}"
fi
NOTE_BANNER=$(printf '> [!NOTE]\n>⚠️ _This is an heavily vibe-coded proof of concept — do not expose it to the internet — use it at your own risk._')
BODY=$(cat <<EOF
${NOTE_BANNER}
## Changelog
### ${CATEGORY}
${CHANGE_TITLE}
**Source:** ${SOURCE_LINE}
**Image:** \`${IMAGE}:${VERSION}\`
**Commits:**
${COMMIT_LIST}
EOF
)
JSON_PAYLOAD=$(jq -n \
--arg tag "v$VERSION" \
--arg name "v$VERSION" \
--arg body "$BODY" \
'{tag_name: $tag, name: $name, target_commitish: "main", body: $body}')
curl -s -o /dev/null -w "Release API response: %{http_code}\n" -X POST \
-H "Authorization: token ${{ secrets.CI_PUSH_TOKEN }}" \
-H "Content-Type: application/json" \
-d "$JSON_PAYLOAD" \
"https://git.djeex.fr/api/v1/repos/Djeex/instameex/releases"
MIRROR_NOTICE="_This github repo is a mirror of https://git.djeex.fr/Djeex/instameex. You'll find full package, PR, history and release note there._"
GH_BODY=$(printf '%s\n\n%s' "$MIRROR_NOTICE" "$BODY")
GH_JSON_PAYLOAD=$(jq -n \
--arg tag "v$VERSION" \
--arg name "v$VERSION" \
--arg body "$GH_BODY" \
--arg sha "${{ github.sha }}" \
'{tag_name: $tag, name: $name, target_commitish: $sha, body: $body}')
GH_STATUS=0
for i in 1 2 3 4 5; do
GH_STATUS=$(curl -s -o /tmp/gh_release.json -w "%{http_code}" -X POST \
-H "Authorization: Bearer ${{ secrets.GH_TOKEN }}" \
-H "Accept: application/vnd.github+json" \
-H "Content-Type: application/json" \
-d "$GH_JSON_PAYLOAD" \
"https://api.github.com/repos/Djeex/instameex/releases")
if [ "$GH_STATUS" = "201" ]; then
break
fi
echo "GitHub Release attempt $i failed (HTTP $GH_STATUS) — mirror may not have synced this commit yet, retrying in 15s..."
sleep 15
done
echo "GitHub Release API response: $GH_STATUS"
if [ "$GH_STATUS" != "201" ]; then
cat /tmp/gh_release.json 2>/dev/null || true
fi
- name: Notify failures
if: always()
uses: ./.cicdeex/notify
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
status: ${{ job.status }}
+1 -1
View File
@@ -1 +1 @@
1.1.1
1.1.8
+11 -6
View File
@@ -1,23 +1,28 @@
# syntax=docker/dockerfile:1
# syntax=docker/dockerfile:1@sha256:572cebbc2b15e6f84c077742952674889cb63cd5e9b80abdffcbe587b6f19183
# ---- Stage 1: compile libultrahdr (ultrahdr_app) --------------------------
FROM alpine:3.21 AS uhdr-build
FROM alpine:3.24.4@sha256:f59abe656b692d901e184be3445e084786602108599d2a51d229c0f5a48c71bf AS uhdr-build
RUN apk add --no-cache \
git cmake make g++ nasm pkgconf libjpeg-turbo-dev
WORKDIR /build
# Pin to a commit once you've confirmed it works for you — HEAD can move.
RUN git clone --depth 1 https://github.com/google/libultrahdr.git
# Pinned to an exact commit (v2.0.2 + fixes) for reproducible, auditable builds.
ARG UHDR_COMMIT=c6fd15cdb2d05d3aaed84b817e4c4a274a4ce600
RUN git init libultrahdr \
&& git -C libultrahdr fetch --depth 1 https://github.com/google/libultrahdr.git "$UHDR_COMMIT" \
&& git -C libultrahdr checkout --detach FETCH_HEAD
RUN cmake -G "Unix Makefiles" -DUHDR_WRITE_XMP=ON \
-S libultrahdr -B libultrahdr/build \
&& cmake --build libultrahdr/build -j"$(nproc)"
# ---- Stage 2: runtime -------------------------------------------------------
FROM python:3.11-alpine AS base
FROM python:3.15.2-alpine@sha256:0f9552bb28711333da16915ec146f5e6bb44a7fdac9ced15dc17c2e0206346dd AS base
RUN apk add --no-cache exiftool libjpeg-turbo libstdc++
# apk upgrade pulls Alpine security fixes released after the base image was built.
RUN apk upgrade --no-cache \
&& apk add --no-cache exiftool libjpeg-turbo libstdc++
COPY --from=uhdr-build /build/libultrahdr/build/ultrahdr_app /usr/local/bin/ultrahdr_app
RUN chmod +x /usr/local/bin/ultrahdr_app
+1 -1
View File
@@ -27,4 +27,4 @@ fi
echo -e "[✓] Required tools found: ultrahdr_app, exiftool"
echo -e "[~] Starting Instameex web server..."
exec gunicorn --bind 0.0.0.0:5000 --workers 1 --threads 4 --timeout 120 main:app
exec gunicorn --no-control-socket --bind 0.0.0.0:5000 --workers 1 --threads 4 --timeout 120 main:app
+1 -37
View File
@@ -1,40 +1,4 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:recommended"],
"timezone": "Europe/Paris",
"labels": ["bot"],
"vulnerabilityAlerts": {
"addLabels": ["bug"]
},
"customManagers": [
{
"customType": "regex",
"description": "Docker images pinned in CI 'docker run' / 'docker create' commands",
"managerFilePatterns": ["/^\\.gitea/workflows/.+\\.ya?ml$/"],
"matchStrings": [
"(?<depName>(?:zricethezav/gitleaks|hadolint/hadolint|aquasec/trivy)):(?<currentValue>v?\\d+\\.\\d+\\.\\d+(?:-[a-z]+)?)"
],
"datasourceTemplate": "docker"
}
],
"packageRules": [
{
"matchManagers": ["pip_requirements"],
"matchUpdateTypes": ["patch", "minor"],
"automerge": true
},
{
"matchManagers": ["dockerfile"],
"matchUpdateTypes": ["patch"],
"automerge": true
},
{
"matchUpdateTypes": ["major"],
"addLabels": ["major"]
},
{
"matchUpdateTypes": ["minor"],
"addLabels": ["minor"]
}
]
"extends": ["local>labeex/renovateex"]
}
+3 -3
View File
@@ -1,5 +1,5 @@
Flask==3.1.3
gunicorn==23.0.0
gunicorn==27.0.1
Pillow==13.0.0
numpy==2.4.6
tifffile==2026.3.3
numpy==2.5.5
tifffile==2026.11.16
+77
View File
@@ -0,0 +1,77 @@
"""End-to-end: runs the real ultrahdr_app + exiftool (present in the Docker
image, skipped elsewhere) to catch regressions from dependency or base image
updates that the mocked unit tests cannot see."""
import shutil
import numpy as np
import pytest
import tifffile
from PIL import Image
from app import assembler
pytestmark = pytest.mark.skipif(
bool(assembler.check_dependencies()) or not shutil.which("exiftool"),
reason="ultrahdr_app/exiftool not installed",
)
SIZE = 128
def gradient():
"""A horizontal ramp 0..1 with a bright highlight block, as float values."""
ramp = np.tile(np.linspace(0.05, 1.0, SIZE, dtype=np.float32), (SIZE, 1))
img = np.stack([ramp, ramp, ramp], axis=-1)
return img
@pytest.fixture
def sdr(tmp_path):
arr = (np.clip(gradient() ** (1 / 2.2), 0, 1) * 255).astype(np.uint8)
path = tmp_path / "sdr.jpg"
Image.fromarray(arr).save(path, "JPEG", quality=95)
return path
@pytest.fixture
def hdr_tiff(tmp_path):
hdr = gradient()
hdr[:32, :32] *= 3.0 # highlight brighter than SDR white
path = tmp_path / "hdr.tif"
tifffile.imwrite(path, hdr.astype(np.float32), photometric="rgb")
return path
def assert_valid_ultrahdr(out, log):
assert out.exists() and out.stat().st_size > 0
with Image.open(out) as img:
assert img.format == "JPEG" and img.size == (SIZE, SIZE)
assert "Validation report" in log # gain map found and readable
assert "XMP-hdrgm:GainMapMax" in log
def test_tiff_pipeline_produces_ultrahdr_jpeg(tmp_path, sdr, hdr_tiff):
out = tmp_path / "out.jpg"
ok, log, warning = assembler.run(sdr, hdr_tiff, out)
assert ok, log
assert_valid_ultrahdr(out, log)
assert warning is False # GainMapMin must not be negative (Instagram rejects it)
def test_jpeg_pipeline_round_trip(tmp_path, sdr, hdr_tiff):
first = tmp_path / "first.jpg"
ok, log, _ = assembler.run(sdr, hdr_tiff, first)
assert ok, log
second = tmp_path / "second.jpg"
ok, log, warning = assembler.run(sdr, first, second) # existing gain-map JPEG as HDR input
assert ok, log
assert_valid_ultrahdr(second, log)
assert warning is False
def test_invalid_hdr_jpeg_fails_cleanly(tmp_path, sdr):
not_hdr = tmp_path / "plain.jpg"
shutil.copy(sdr, not_hdr) # a JPEG without any gain map
ok, log, warning = assembler.run(sdr, not_hdr, tmp_path / "out.jpg")
assert ok is False and warning is False
assert log.splitlines()[-1].startswith("Error:")