Edit photos by describing the change, on your own GPU. A free, open-source alternative to Nano Banana and ChatGPT image editing: photos stay on your computer, no daily limit. One installer for Windows, Mac and Linux sets up the best open model (Qwen-Image 2.1). MCP server for AI agents.
TypeScript ai-photo-editorcomfyui-alternativegenerative-fillimage-editingimage-generationinpaintinglinuxlocal-aimacosmcpmcp-servernano-banana-alternativeofflinephoto-editorprivacyqwen-imageqwen-image-2-1stable-diffusion-cppvulkanwindows
feat(ui): show the painted area on the stage image
Gabriele Lozuponedcc1efa354be
diff --git a/src/components/Compare.tsx b/src/components/Compare.tsxindex e4ed28a..055af57 100644--- a/src/components/Compare.tsx+++ b/src/components/Compare.tsx@@ -26,7 +26,7 @@ const DIFF_SIDE = 1024;const isTyping = (t: EventTarget | null) => t instanceof HTMLElement && (t.isContentEditable || ["INPUT", "TEXTAREA", "SELECT"].includes(t.tagName));/** The result with the selected comparison view, sized to fit the stage (or the screen). */-export function CompareFrame({ g, base, fullscreen = false, onFullscreen }: { g: GenerationRecord; base: CompareBase; fullscreen?: boolean; onFullscreen?: () => void }) {+export function CompareFrame({ g, base, fullscreen = false, maskSrc, onFullscreen }: { g: GenerationRecord; base: CompareBase; fullscreen?: boolean; maskSrc?: string; onFullscreen?: () => void }) {const mode = useStore((s) => s.compare);const flickerMs = useStore((s) => s.flickerMs);const { ref, box } = useFit(g.width / g.height);@@ -111,6 +111,8 @@ export function CompareFrame({ g, base, fullscreen = false, onFullscreen }: { g:><img className="compare-img" src={after} alt={g.prompt} draggable={false} />{mode === "diff" && !holding && <DiffCanvas after={after} before={before} rect={base.rect} tagStyle={tag("left")} />}+ {/* The area painted for the next edit, on the result (the original covers it when shown). */}+ {maskSrc && <img className="stage-mask" src={maskSrc} alt="" draggable={false} />}{/* The original stays mounted (hidden) so switching is instant. */}<divclassName="compare-before"diff --git a/src/components/Stage.tsx b/src/components/Stage.tsxindex 291027e..453153c 100644--- a/src/components/Stage.tsx+++ b/src/components/Stage.tsx@@ -377,13 +377,14 @@ function InputActions({ item }: { item: SessionItem }) {/** A result or input fitted to the stage (never enlarged past its own size), with the* full-screen button in its top-right corner. */-function PlainFrame({ src, alt, w, h, onFullscreen }: { src: string; alt: string; w: number; h: number; onFullscreen: () => void }) {+function PlainFrame({ src, alt, w, h, maskSrc, onFullscreen }: { src: string; alt: string; w: number; h: number; maskSrc?: string; onFullscreen: () => void }) {const { ref, box } = useFit(w / h);const bw = Math.min(box.w, w);return (<div className="stage-frame" ref={ref}><div className="image-box" style={{ width: bw, height: bw * (h / w) }}><img className="stage-img fill" src={src} alt={alt} draggable={false} />+ {maskSrc && <img className="stage-mask" src={maskSrc} alt="" draggable={false} />}<FullscreenButton onOpen={onFullscreen} /></div></div>@@ -693,6 +694,11 @@ export function Stage() {const [originalOf, setOriginalOf] = useState<string | null>(null);const [full, setFull] = useState(false);const canFull = !!item && viewable(item);+ // The area painted for the next edit, shown on the image it belongs to (the prompt's first image).+ const mask = useStore((s) => s.composer.mask);+ const ref0 = useStore((s) => s.composer.refs[0]);+ const itemSource = item?.gen ? `gen:${item.gen.id}` : item?.input ? `input:${item.input.id}` : null;+ const maskSrc = mask && ref0 && mask.refKey === ref0.key && ref0.source === itemSource ? urls.input(mask.inputId) : undefined;// F opens full screen on the selected version (Esc or F again closes it).useEffect(() => {@@ -748,9 +754,9 @@ export function Stage() {{g && from && showOriginal ? (<PlainFrame key={`original-${g.id}`} src={urls.genOriginal(g.id)} alt={`${g.prompt} (before upscaling)`} w={from.width} h={from.height} onFullscreen={openFull} />) : item.gen && base ? (- <CompareFrame key={`compare-${item.gen.id}`} g={item.gen} base={base} onFullscreen={openFull} />+ <CompareFrame key={`compare-${item.gen.id}`} g={item.gen} base={base} maskSrc={maskSrc} onFullscreen={openFull} />) : (- <PlainFrame key={src} src={src} alt={item.gen?.prompt ?? item.input?.original_name ?? ""} w={w} h={h} onFullscreen={openFull} />+ <PlainFrame key={src} src={src} alt={item.gen?.prompt ?? item.input?.original_name ?? ""} w={w} h={h} maskSrc={maskSrc} onFullscreen={openFull} />)}<StageBar item={item} label={labels[item.key]} showOriginal={showOriginal} setShowOriginal={(on) => setOriginalOf(on && g ? g.id : null)} /></>diff --git a/src/styles.css b/src/styles.cssindex 975e450..4cad223 100644--- a/src/styles.css+++ b/src/styles.css@@ -390,6 +390,8 @@ pre.diag { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font.compare-overlay .seg button.on { background: rgba(255, 255, 255, 0.92); color: #111; box-shadow: none; }.compare-box { position: relative; border-radius: 6px; overflow: hidden; touch-action: none; user-select: none; background-image: conic-gradient(var(--checker) 25%, transparent 0 50%, var(--checker) 0 75%, transparent 0); background-size: 16px 16px; }.compare-box.slider { cursor: ew-resize; }+/* the area painted for the next edit, drawn like in the inpaint editor */+.stage-mask { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 6px; mix-blend-mode: difference; opacity: 0.75; pointer-events: none; }.compare-box.slider.zoomed { cursor: inherit; }.compare-img, .compare-diff { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }/* Areas the original did not cover (expanded edges) show the checkerboard. */