#!/usr/bin/env python3 """Orange pipeline: rembg variants composited over backgrounds and originals.""" from pathlib import Path from imagepipeline import Pipeline INPUT = Path("/home/frank/pics/20260726_Hellraisers Schlossplatz die Zweite/darktable_exported/png") OUTPUT_BASE = Path.home() / "pipeline_output" # Reuse outputs from a previous run or external folder (key = step id, e.g. rembg_01). EXISTING_OUTPUTS: dict[str, Path] = {} # Resume an aborted run: point to its output root folder (or None for a fresh run). CONTINUE_FROM: Path | None = None COLOR1 = "#732f74" COLOR2 = "#552577" # COLOR1 = #732f74 -> 45,18,45; COLOR2 = #552577 -> 33,14,46 GMIC_DROP_SHADOW = "-fx_drop_shadow3d 0,0,0,10,1,1,2,0.5,33,14,46,200,0" GMIC_BWRECOLOR = ( "-fx_bwrecolorize 0,0,0,0,0,1,0,2,33,14,46,255,45,18,45,255," "158,137,189,255,224,191,228,255,45,18,45,255,255,255,255,255,255,255," "255,255,45,18,45,255" ) GMIC_GRADIENT_A = ( '-fx_custom_gradient 0,0,0,1,2,1,0,128,100,100,2,0,1,0,"",1,0,45,18,45,255,' "33,14,46,255,255,255,0,255,255,255,255,255,0,255,255,255,0,255,0,255,0,0," "255,255,128,128,128,255,255,0,255,255,0,0,0,0" ) GMIC_GRADIENT_B = ( '-fx_custom_gradient 0,0,0,1,2,1,0,128,100,100,2,0,1,0,"",1,0,33,14,46,255,' "45,18,45,255,255,255,0,255,255,255,255,255,0,255,255,255,0,255,0,255,0,0," "255,255,128,128,128,255,255,0,255,255,0,0,0,0" ) def main() -> None: with Pipeline( name="orange", input_dir=INPUT, output_base=OUTPUT_BASE, existing_outputs=EXISTING_OUTPUTS or None, continue_from=CONTINUE_FROM, ) as p: rembg_out = p.step("rembg", inputs="input") grayscale = p.step("gmic_grayscale", inputs="input") rembg_shadow = p.step("gmic", inputs=rembg_out, command=GMIC_DROP_SHADOW) rembg_bwrecolor = p.step("gmic", inputs=rembg_out, command=GMIC_BWRECOLOR) color_bg = p.step("imagemagick_fill", inputs="input", color1=COLOR1) # combine: original, rembg (drop shadow), rembg shadow_mid = p.step("composite", inputs=["input", rembg_shadow]) p.step("composite", inputs=[shadow_mid, rembg_out]) # combine: original, rembg (bw recolorize @ 50%), rembg bw_mid = p.step( "composite", inputs=["input", rembg_bwrecolor], foreground_opacity=0.5, ) p.step("composite", inputs=[bw_mid, rembg_out]) # combine: original (grayscale), rembg p.step("composite", inputs=[grayscale, rembg_out]) # combine: color background, rembg (drop shadow), rembg shadow_color_mid = p.step("composite", inputs=[color_bg, rembg_shadow]) p.step("composite", inputs=[shadow_color_mid, rembg_out]) output_root = p.run() print(f"Pipeline finished. Output: {output_root}") if __name__ == "__main__": main()