Files
imagepipeline/imagepipeline/modules/gmic.py
T
Frank Schwenk ce431d7eec feat: resume fixes, OpenRouter templates, and project context
Delegate expected output filenames to modules so resume works for rembg
and composite; normalize G'MIC multi-frame output; add OpenRouter style
reference support with tests. Add Crusaders, orange, and team gallery
pipelines plus SOUL/AGENTS context files.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-12 10:45:00 +02:00

39 lines
1.4 KiB
Python

from __future__ import annotations
from imagepipeline.core.context import ModuleContext
from imagepipeline.core.params import Param
from imagepipeline.modules.base import SubprocessModule
from imagepipeline.modules.registry import register
from imagepipeline.utils.gmic import finalize_gmic_output, split_gmic_command
from imagepipeline.utils.subprocess import run_command
@register
class GmicModule(SubprocessModule):
name = "gmic"
description = "Run a G'MIC command on each input image"
command_candidates = ("gmic",)
default_timeout = 300.0
@classmethod
def parameters(cls) -> dict[str, Param]:
return {
"command": Param(
"string",
required=True,
help="G'MIC command(s) applied before -output (e.g. '-fx_drop_shadow3d ...')",
),
}
def run(self, ctx: ModuleContext) -> None:
ctx.output_dir.mkdir(parents=True, exist_ok=True)
gmic_command = ctx.params["command"]
total = len(ctx.input_paths)
for index, src in enumerate(ctx.input_paths, start=1):
self.log_image(ctx, index, total, src)
dst = ctx.output_dir / src.name
cmd = ["gmic", str(src), *split_gmic_command(gmic_command), "-output", str(dst)]
run_command(cmd, timeout=self.default_timeout)
finalize_gmic_output(ctx.output_dir, dst)