#!/bin/bash # Plug-ins for Photoshop users, installed the official Flathub way next to the Flathub GIMP: # Resynthesizer (Heal Selection) and G'MIC-Qt. Checks that GIMP 3.2 registers them and runs Heal Selection. set -u cd "$(dirname "$0")/.." REPO=$(pwd) OUT="$REPO/verify/${VERIFY_OUT:-results-plugins}"; mkdir -p "$OUT" LOG="$OUT/run-log.txt" log() { echo "[$(date +%H:%M:%S)] $*" | tee -a "$LOG"; } sudo apt-get update -qq >/dev/null 2>&1; sudo DEBIAN_FRONTEND=noninteractive apt-get install -y -qq flatpak python3-pil >/dev/null 2>&1 flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo >>"$LOG" 2>&1 log 'install GIMP + plug-ins from Flathub' flatpak install --user -y --noninteractive flathub org.gimp.GIMP > "$OUT/install-gimp.txt" 2>&1; log "gimp exit $?" flatpak search org.gimp.GIMP.Plugin > "$OUT/flathub-plugins.txt" 2>&1 for p in Resynthesizer GMic; do flatpak install --user -y --noninteractive flathub "org.gimp.GIMP.Plugin.$p//3" > "$OUT/install-$p.txt" 2>&1; log "$p exit $?" done flatpak list --user --columns=application,version,branch > "$OUT/flatpak-list.txt" log 'probe inside GIMP' PROBE_OUT="$OUT" PROBE_IMG="$REPO/assets/moraine-lake.jpg" timeout 600 flatpak run --env=PROBE_OUT="$OUT" --env=PROBE_IMG="$REPO/assets/moraine-lake.jpg" \ --command=gimp-console org.gimp.GIMP -i --batch-interpreter=python-fu-eval -b "exec(open('$REPO/verify/plugin_probe.py').read())" > "$OUT/probe-console.txt" 2>&1 log "probe exit $?" python3 - "$OUT" "$REPO/assets/moraine-lake.jpg" <<'PY' import json, sys from PIL import Image, ImageChops out, src = sys.argv[1], sys.argv[2] r = json.load(open(f'{out}/plugin-probe.json')) if r.get('heal_output'): x, y, w, h = r['heal_rect'] a = Image.open(src).convert('RGB').crop((x, y, x + w, y + h)); b = Image.open(r['heal_output']).convert('RGB').crop((x, y, x + w, y + h)) d = ImageChops.difference(a, b).convert('L'); hist = d.histogram() changed = sum(hist[16:]) / (w * h) r['heal_changed_share'] = round(changed, 3) Image.open(src).convert('RGB').crop((x - w, y - h, x + 2 * w, y + 2 * h)).save(f'{out}/heal-before.png') Image.open(r['heal_output']).convert('RGB').crop((x - w, y - h, x + 2 * w, y + 2 * h)).save(f'{out}/heal-after.png') json.dump(r, open(f'{out}/plugin-probe.json', 'w'), indent=1) print(json.dumps({k: v for k, v in r.items() if k != 'procedures'}, indent=1)); print(sorted(r['procedures'])) PY log done