SD-PPP Documentation

repository·main·Indexed 23 days ago

https://github.com/zombieyang/sd-ppp

An unofficial AI plugin for Adobe Photoshop (PS26.0+) that integrates AI models from replicate.com and runninghub.ai, including Flux and Midjourney. It features ComfyUI integration without custom nodes, specialized ComfyUI nodes for Photoshop document and layer management (e.g., GetLayerNode, GetDocumentNode), and a TypeScript-based framework for managing workflows, socket communication, and UI form generation within Photoshop.

Tokens
5.6K
Snippets
15
Records
41
Agent score
84%

What's inside SD-PPP

  1. Overview of SD-PPP features

    main

    SD-PPP is an unofficial Photoshop AI plugin that integrates various AI generation capabilities into the Photoshop workflow.

    Key features in version 2.0 Beta include:

    • Model Support: Use any models/AIApps from replicate.com and www.runninghub.ai (including Nano-banana, Flux-Kontext-Pro/Max, and Midjourney via RunningHUB).
    • ComfyUI Integration: Works with ComfyUI without needing to install custom nodes.
    • Enhanced UI: Improved interface specifically for sending and receiving images.
    • Workflow Efficiency:
      • Keyboard shortcuts for image selection.
      • Rapid selection of any area, layer, or document within Photoshop.
  2. Install SD-PPP 2.0 Beta

    main

    SD-PPP 2.0 Beta allows you to use any models and AIApps from replicate.com and www.runninghub.ai directly within Photoshop. It also supports ComfyUI without requiring custom nodes.

    Requirements:

    • Adobe Photoshop 2025 (PS26.0) or newer.

    To download the installer, visit the official download page.

    [> Download 2.0 Beta](https://sdppp.zombee.tech/)
  3. How Document and Layer inputs resolve source nodes

    main

    In the ComfyUI node implementation for SD-PPP, DocumentInput and LayerInput are specialized input types used to retrieve document data from connected nodes.

    When a node has a DocumentInput or LayerInput connected, the system uses findSourceNodeByInput to traverse the graph backwards from the current input. It follows links through any intermediate 'Reroute' nodes to find the original source node. If the source node implements the required interface (NodeWithDocumentOutput or NodeWithLayerOutput), the input provides access to the documentWidget associated with that source node.

  4. Register custom node converters with sdpppX.widgetable.add

    main

    To control how specific ComfyUI nodes are mapped to the SD-PPP form structure, you can register custom converters using sdpppX.widgetable.add. This allows you to define a formatter (to transform a node into a WidgetTableStructureNode) and an optional setter (to write values back to the node).

    Converters can be registered using a wildcard pattern (e.g., * for any node type) or a specific node type name. You can also register a __DEFAULT__ converter to act as a fallback for all nodes.

  5. Create unique identifiers for Photoshop layers and documents

    main

    The makeLayerIdentify and makeDocumentIdentify functions generate unique string-based identifiers used to track specific Photoshop layers or documents.

    • makeLayerIdentify(id, name, level): Creates a layer identifier. It includes the layer name, the ID, and an optional level parameter that prepends dashes (-) to the name to represent hierarchy depth.
    • makeDocumentIdentify(id, name): Creates a document identifier using the format name (id:id).
  6. Manage Photoshop state with PhotoshopStore

    main

    The PhotoshopStore class is used to manage and mutate the state of the Photoshop plugin. It extends MainStore and provides several @StoreMutation methods to update specific parts of the state.

    Available Mutations

    • setIsLocal(isLocal: boolean): Sets the local environment flag.
    • setUName(uid: string): Sets the instance name (automatically prefixes with PS_).
    • setDocument(activeDocumentID: number, documents: PhotoshopDataDocument): Updates the active document ID and the collection of available documents.
    • setCanvasStateID(historyStateID: number): Updates the ID for the last canvas change.
    • setSelectionStateID(selectionState: string): Updates the ID for the last selection change.
    • setHistoryStateID(historyStateID: number): Updates the overall Photoshop history state ID.
    • setComfyUserToken(comfyUserToken: string): Updates the ComfyUI user token.
    • setActions(actions: string[]): Updates the list of current actions.
  7. Generate a widget table structure with makeWidgetTableStructure

    main

    Use makeWidgetTableStructure to transform a full ComfyUI graph into a WidgetTableStructure. This structure is used to render the UI form in Photoshop.

    Key behaviors:

    • Filtering: Only nodes that are not muted and have a valid title (not starting with .) are included.
    • Naming: Nodes intended for the UI should have titles starting with # (unless a custom converter is provided).
    • Grouping: It preserves ComfyUI groups, mapping their IDs and colors.
    • Weighting: It calculates uiWeightSum for nodes based on their widgets' uiWeight (defaulting to 12 per widget).