Developer guide

From the repository root, follow Download and install to create an environment. Reproduce the operation with the small bundled fixtures before editing. Afterward, repeat it with the same inputs and compare the display, cache, and exported files.

Find the implementation

The implementation files below are in src/mulimgviewer/src/. The GUI definitions are in the adjacent gui/ directory.

Behaviour to change

Start here

Main window, opening sources, buttons, and drawing interactions

main.py. For image sources and index data, see data.py.

Frame extraction, long-video seeking, and video cache scheduling

video_source.py、video_decoder.py、video_manager.py

Asynchronous image display, playback timing, and task budgets

image_pipeline.py、playback_controls.py、playback_policy.py、pipeline_executor.py

Algorithm execution, layout, and cache paths

custom_pipeline.py、render_layout.py、cache_layout.py

Background saving and encoding

export_controller.py、image_encoding.py

Configuration, settings sidebar, status bar, and index table

configuration.py、settings_panel.py、status_bar.py、index_table.py

Change the GUI

  1. Open the relevant .fbp file, such as src/mulimgviewer/gui/main_gui.fbp, in wxFormBuilder. Edit the controls and event bindings there.

  2. Run python tools/generate_gui.py to regenerate the interface. If the generator is outside PATH, append --generator "full path to executable". Use --check to compare the generated files with the definitions.

  3. Connect callbacks in the implementation layer. Keep layout edits grouped until manual refresh. Background tasks use applied settings, and exports capture settings when Save is clicked. For new controls, check load, save, reset, and compatibility with old configurations.

  4. Exercise the change in the main window with both image and video inputs, then run the relevant tests.

Add an image processing algorithm

Implement a single-image kernel in src/mulimgviewer/src/custom_func/<algorithm>/main.py. The built-in Gaussian Blur illustrates the interface:

from PIL import ImageFilter

THREAD_SAFE = True

def process_image(image, *, context):
    return image.filter(ImageFilter.GaussianBlur(radius=2))

Accept and return Pillow images. The framework handles caching and export. Declare THREAD_SAFE = True only if calls can safely overlap. For a reusable model, return a context from setup() and access it through context during processing. The framework reuses it within the algorithm session. For batches, implement process_batch(images, *, context) and return the same number of outputs in input order. See examples/custom_func/GPU Sharpen/ for device setup, batching, and cleanup.

Start with Selected to verify one algorithm, then compare with All algorithms. Once source frames are ready, workers process each algorithm, stitch its panel, and compose the final page. Check how stale results behave after layout changes, rapid navigation, and window closure. Measure whole-page playback as well as individual kernels.

Performance and regression testing

Keep sources, layout, display scale, algorithms, and cache window fixed when comparing runs. Record cold-start time to first page, time to first page after a deep seek, sustained playback and supply FPS, CPU, and memory. Include the power mode, OS, and processor. Report cold and cached results separately. Start with python auto_test_scripts/performance/benchmark_video_playback.py --help.

Regression tests and pull request review

When adding a feature or fixing a bug, follow these steps to check existing behaviour. Attach the resulting report to the pull request for review.

Step 1. Open the repository and verify the Python environment

Open a terminal at the repository root, which contains MulimgViewer.py, src, and auto_test_scripts. Use a Python environment that can launch the application. For Conda, substitute your environment’s name below.

conda activate mulimgviewer
python -c "import sys; from pathlib import Path; print(sys.executable); print(Path.cwd()); assert Path('MulimgViewer.py').is_file()"

Run all test commands from the repository root. Tests use isolated processes and temporary directories with bundled inputs. Personal images, videos, and configuration files are unnecessary.

Step 2. Install dependencies and prepare video tools

python -m pip install -r auto_test_scripts/requirements.txt

Video tests require both FFmpeg and FFprobe. If they are missing, Conda users can install them with the following command.

conda install -c conda-forge ffmpeg

The runner uses the application’s own video tool discovery. A missing dependency produces a failed report.

On Windows, you can also double-click auto_test_scripts/run_tests.cmd in the activated environment. If it picks the wrong Python, specify your interpreter in PowerShell, substituting your own path below.

$env:MULIMGVIEWER_PYTHON = 'C:\path\to\environment\python.exe'
& .\auto_test_scripts\run_tests.cmd --strict-skips

Linux and macOS can use the same Python entry point or sh auto_test_scripts/run_tests.sh. GUI tests require a graphical session. On headless Linux, install Xvfb and run:

xvfb-run -a python auto_test_scripts/run_tests.py --strict-skips

Step 3. Run the full regression suite

python auto_test_scripts/run_tests.py --strict-skips

Wait for all modules to finish. Look for PASSED and exit code 0. A run typically takes several minutes. With --strict-skips, failures, errors, missing dependencies, timeouts, and skipped cases all fail the check.

Keep source code, tests, and fixtures unchanged during a run. Run only one full suite per working directory at a time. The report records the commit SHA, uncommitted changes, and fingerprints of source, tests, and assets. Rerun if any change during testing.

Coverage includes image and video playback, four input modes, combined parallel/sequential browsing, layouts, titles, algorithms, two-level caching, index and status bar, and configuration restore. Export tests cover seven output combinations, three formats, background saving, and pause/resume. Fixed PNG, processed, and stitched outputs are compared pixel by pixel. Video decoding is checked against known frames.

Fixtures in auto_test_scripts/assets include small images, videos, relative path lists, and expected outputs (about 38 KB in total). Normal test runs leave expected outputs untouched. An earlier verified Windows run is recorded in auto_test_scripts/baseline/verified.json. Use the current report for actual case counts.

Step 4. Open the report and check the result

Each run creates auto_test_scripts/reports/<UTC timestamp>/. Read the directory field in auto_test_scripts/reports/latest.json to locate the latest run. In Windows PowerShell, use:

$reportInfo = Get-Content -Raw auto_test_scripts/reports/latest.json | ConvertFrom-Json
$reportPath = Join-Path auto_test_scripts/reports $reportInfo.directory
Invoke-Item (Join-Path $reportPath 'report.html')

File

Purpose

report.html

Browse feature groups, case and subtest results, and tracebacks.

report.json

Check the commit, source fingerprint, environment, and full results.

junit.xml

Provide machine-readable results for CI and JUnit tools.

summary.md

Read a summary of failures, skips, and environment errors.

test_*.log

Inspect a module’s execution log.

PASSED means all selected cases passed. PASSED_WITH_SKIPS includes skipped cases. FAILED means the check failed. For full regression review, verify every module ran and every feature group was checked. A passing subset only covers the selected cases.

Step 5. Diagnose failures and rerun

Find the failing case in the HTML report, including its input mode, output combination, layout, and format. Then inspect the matching module log. Narrow down the failure with these commands:

python auto_test_scripts/run_tests.py --list
python auto_test_scripts/run_tests.py --module test_export_modes --module test_reference_workflows
python auto_test_scripts/run_tests.py --module test_video_gui_async --case '*background_save*'

You can also rerun failed cases from a report. In the PowerShell session from step 4, run:

python auto_test_scripts/run_tests.py --failed "$reportPath/report.json"

Determine whether the cause is an application defect, an outdated test assumption, or the environment. Preserve assertions and expected images while investigating. Removing assertions, skipping failures, or overwriting references can hide a regression. After the fix, repeat the full strict run in step 3.

Step 6. Add tests for the change

Write unittest cases in auto_test_scripts/cases/test_*.py for automatic discovery. Use parameterized subTest blocks for input, layout, and output combinations so reports identify the failing combination. Update the feature mapping in auto_test_scripts/coverage.json.

Use fixed fixtures or private temporary copies. Avoid personal paths, network access, and user files. For asynchronous changes, cover dependencies, memory admission, pause, cancellation, and cleanup on close. For export changes, check contents, actual format, and directory structure.

Run python auto_test_scripts/generate_assets.py only for deliberate fixture specification changes. Review the generator, inputs, expected results, and manifest.json together to avoid accepting incorrect output as a new reference.

Step 7. Submit the pull request with its report

Finish code and test changes, then run the full strict suite. Explain the purpose, affected features, new cases, and remaining manual checks in the PR. Complete the regression section of the PR template.

Open the Functional regression report workflow in GitHub Actions after submission. Check that windows-regression passed and download the report for the relevant commit. Link the CI run or artifact in the PR. For local reports, bundle the HTML, JSON, JUnit results, and module logs.

Git ignores generated auto_test_scripts/reports. Individual run logs do not need committing. The existing baseline/verified.json is a historical baseline. Rerun the suite and update the report link after subsequent edits.

Reviewers should check that the report matches the latest PR commit, covers the full suite, explains any failures or skips, and includes cases for the change. Repository administrators can make windows-regression a required check in branch protection or repository rules.

CI currently runs on Windows. Verify Linux/macOS, real GPU hardware and drivers, system dialog appearance, and long-running behaviour where relevant. See auto_test_scripts/README.md for case details and maintenance guidance.

Build offline desktop bundles

Build for multiple platforms at once. In the GitHub repository, open Actions → Desktop packages → Run workflow, choose a branch, and start the run. Jobs build natively for Windows x64, Linux x64/ARM64, and Intel/Apple Silicon macOS. Each uploads its artifact after the extracted bundle passes its check. Download the artifact from the run and open GitHub’s outer ZIP to find the actual archive. Attach the desired artifacts when preparing a release.

Build locally. Run the commands below from the root of a Git checkout on the target system. Linux requires a graphical session. On a headless host, install Xvfb and xauth, then replace the final command with xvfb-run -a python tools/package_desktop.py --compact. Allow network access for dependencies and enough disk space for the runtime, archive, and extracted copy.

conda create -y -n mulimg-builder -c conda-forge python=3.11
conda activate mulimg-builder
python tools/package_desktop.py --compact

All three platforms write a .tar.xz named for the OS and architecture under dist/desktop/. Omitting --compact selects ZIP on Windows and tar.gz on Linux and macOS. After extraction, follow Installation and verification. The macOS binary is unsigned and unnotarized. Linux requires compatible system libraries and a graphical session.

Build and verification. The script creates a temporary Conda environment from environment.yml, skips user-configured default packages, and installs PyInstaller there. PyInstaller collects dependencies in directory mode. The build explicitly includes FFmpeg, FFprobe, bundled algorithms, and resources and publishes the archive after its extracted copy passes the self-check.

Add new bundled algorithm sources and resources to Git. Include dynamically imported dependencies in the build environment and verify that PyInstaller collects them. Before release, open two videos on a clean target machine, run the intended algorithms, export a page, and reopen it.

Compact compression preserves the runtime files and trades additional build time and temporary disk space for a smaller download.

Run Actions → Compare desktop packages on a single commit to compare packagers. Each native platform builds Conda and PyInstaller onedir tar.xz archives and tests the extracted GUI, video, built-in algorithm and exports. Each job summary records the verified download size in bytes. Compare results on the same OS and architecture, then try the custom algorithms you plan to distribute.

Build the documentation and maintain translations

Run these commands from the repository root, then open docs/_build/html/zh-cn/index.html in a browser. Generate the POT templates successfully before updating the English catalogues.

python -m pip install -r docs/requirements.txt sphinx-intl
python -m sphinx -b html docs docs/_build/html/zh-cn
python -m sphinx -b gettext docs docs/_build/gettext
python -m sphinx_intl update -p docs/_build/gettext -d docs/locale -l en

Fill in or review each msgstr in the matching PO file under docs/locale/en/LC_MESSAGES/. Remove the fuzzy flag from reviewed entries. Preserve commands, paths, and link targets, then run:

python -m sphinx_intl build -d docs/locale -l en
python -m sphinx -b html -D language=en docs docs/_build/html/en

Read the Docs uses the configuration from each branch or tag. It installs the documentation dependencies and reads the version and icon directly from the checkout.

Prepare a release

See Build and publish a release to prepare the release commit, verify packages and push the release tag.