A simple Stable Diffusion WebUI extension that adds a Photopea tab and integration.

Overview

Photopea Stable Diffusion WebUI Extension

Demo video

Photopea is essentially Photoshop in a browser. This is a simple extension to add a Photopea tab to AUTOMATIC1111 Stable Diffusion WebUI.

In the tab, you will have an embedded Photopea editor and a few buttons to send the image to different WebUI sections, and also buttons to send generated content to the embeded Photopea.

Consider supporting Photopea by going premium!

Installation

On your Stable Diffusion WebUI, click the Extensions tab, then the Install from URL internal tab in that section. Paste the URL for this repo and click Install.

Usage

In the Photopea extension tab, you will have the embedded Photopea window. It literally just embeds the exact same Photopea you'd have when accessing the website directly. You can learn how to use Photopea in their official documentation.

Options:

  • Active Layer Only: if this box is ticked, only the currently selected layer in Photopea will be sent to the WebUI when using one of the buttons.
  • iFrame height: by default, the Photopea embed is 768px tall, and 100% wide. If you have more or less monitor real estate, you can use the slider to increase or decrease the size of the Photopea window in your tab.

Buttons:

  • Send to Extras: sends the currently opened image's flattened contents to the Extras tab. Useful for upscaling etc.
  • Send to img2img: same as above, but sends the image to the img2img tab.
  • Inpaint Selection: in case there's an area selected in the active document, will create a mask with that shape and send both the mask and the image to img2img's "Inpaint Upload" tab.

ControlNet:

In case you have the ControlNet extension installed, you'll also have:

  • ControlNet model index dropdown menu: in the WebUI Settings tab, you can set up more than one ControlNet to be run at the same time. This dropdown lets you choose which model the image will be sent to.
  • Send to txt2img ControlNet button: sends the image to ControlNet in the txt2img tab.
  • Send to img2img ControlNet button: sends the image to ControlNet in the ixt2img tab.

WebUI image galleries

In the txt2txt, img2img and extras tab galleries (where your generated images appear), there will also be a Send to Photopea button. You can press it to send the currently selected image back to the Photopea tab. It will be added as a new rasterized layer to the currently open document.

Known bug: when large files are passed in, they might not instantly be rasterized (this happens due to Photopea loading the image asynchronously, but sending the response to the load request before the image is fully loaded).

You can also copy and paste the generated results normally into Photopea, and have multiple documents open etc.

Changelog

2023-06-17

  • Fixed ControlNet tab auto-uncollapse when sending images from Photopea.
  • Patched Send to Photopea on Vladmandic fork (solution suggested by bananasss00)
  • Fixed a bug where Send to Photopea would not appear when using --hide-ui-dir-config (solution suggested by Odls)

2023-05-13

  • Added Send to Photopea button in the extras tab.
  • Fixed a bug where exporting a single layer, or using inpaint selection, would not work on documents with folders in them.

Code & Usage Licenses

I've tried to comment the code thoroughly, especially because it's mostly JS hacks. Feel free to take it apart and reuse it.

When it comes to usage of the extension, I'm adding restriction guidelines from CreativeML Open RAIL-M license.

You agree not to use the extension or derivatives of the extension:

  • In any way that violates any applicable national, federal, state, local or international law or regulation;

  • For the purpose of exploiting, harming or attempting to exploit or harm minors in any way;

  • To generate or disseminate verifiably false information and/or content with the purpose of harming others;

  • To generate or disseminate personal identifiable information that can be used to harm an individual;

  • To defame, disparage or otherwise harass others;

  • For fully automated decision making that adversely impacts an individual’s legal rights or otherwise creates or modifies a binding, enforceable obligation;

  • For any use intended to or which has the effect of discriminating against or harming individuals or groups based on online or offline social behavior or known or predicted personal or personality characteristics;

  • To exploit any of the vulnerabilities of a specific group of persons based on their age, social, physical or mental characteristics, in order to materially distort the behavior of a person pertaining to that group in a manner that causes or is likely to cause that person or another person physical or psychological harm;

  • For any use intended to or which has the effect of discriminating against individuals or groups based on legally protected characteristics or categories;

  • To provide medical advice and medical results interpretation;

  • To generate or disseminate information for the purpose to be used for administration of justice, law enforcement, immigration or asylum processes, such as predicting an individual will commit fraud/crime commitment (e.g. by text profiling, drawing causal relationships between assertions made in documents, indiscriminate and arbitrarily-targeted use).


Comments
  • Sending to

    Sending to "inpaint upload" doesn't work

    I can use all other functions, but sending a active selection in photopea to "inpaint upload" doesn't work. I deactivated my other extensions and restarted A1111, but that didn't change anything This both doesn't work on Opera and Chrome Browser under Windows 11 for me

    opened by OlivioSarikas 6
  • [Feature Request]: Support tablets

    [Feature Request]: Support tablets

    Using a mouse when trying to "paint" delicate forms can get quite cumbersome fast. I would like to suggest to support pens and tablets like we use in Photoshop. If necessary even as a checkbox option to switch on and off. Would be really great! 🙂

    opened by Woisek 4
  • Latest Stable Diffusion (v1.3.0) + Latest ControlNet (v1.1.204) sending to (Txt2Img / Img2Img) ControlNet not working

    Latest Stable Diffusion (v1.3.0) + Latest ControlNet (v1.1.204) sending to (Txt2Img / Img2Img) ControlNet not working

    Seems not to send anything to ControlNet in the latest versions using the "Send to" buttons. Send to Img2Img & Send to Extras seem to be working fine.

    Thanks for your work.

    opened by xioustic 3
  • Add the button to send from extras(upscale tab) to photopea

    Add the button to send from extras(upscale tab) to photopea

    Add the button to send from upscale tab to photopea. It would have been extremely nice if that button had been there. изображение Right now I only see the button from the photopea tab in extras. If there was a send button from extras, this case would work:

    txt2img -> photopea(edit some part) -> extras -> back to photopea with upscaled image.

    opened by viktor02 3
  • no selection in active document

    no selection in active document

    I can't send the image over to inpaint.

    all the other buttons work such as:

    1. send to img2img controlnet
    2. send to extras
    3. send to txt2img controlnet
    4. send to img2img

    inpaint selection I get a "no selection in active document"

    https://github.com/yankooliveira/sd-webui-photopea-embed/assets/128274207/7d16cced-e988-43e3-941b-fa0ae47691aa

    opened by Gcode808 2
  • [Feature Request] Inpaint masked instead of selected

    [Feature Request] Inpaint masked instead of selected

    Selection is often short-lived, and users generally have less control on the selection than mask on an image. Should we consider use the actual mask attached to the image in Photopea as the inpaint mask in A1111?

    opened by huchenlei 2
  • [Bug] Not correctly handle layer.typename

    [Bug] Not correctly handle layer.typename

    Following code has issue checking whether a layer is of type LayerSet.

        // Gets all layers recursively, including the ones inside folders.
        function getAllArtLayers (document, layerCollection){
            for (var i = 0; i < document.layers.length; i++){
                var currentLayer = document.layers[i];
                if (currentLayer.typename === "ArtLayer"){
                    layerCollection.push(currentLayer);
                } else {
                    getAllArtLayers(currentLayer, layerCollection);
                }
            }
            return layerCollection;
        }
    

    There are many other layer types other than ArtLayer and LayerSet:

    1. ArtLayer: This is the most basic type of layer, containing raster images, text, or solid colors.

    2. LayerSet: A layer set, or a group of layers, which can contain other ArtLayers or LayerSets.

    3. TextItem: This represents a text layer. It is not a type of layer by itself, but an object contained in an ArtLayer that you can manipulate if the ArtLayer.kind property is LayerKind.TEXT.

    4. SolidFill: This represents a solid color fill layer. Similar to TextItem, it's an object you would manipulate if ArtLayer.kind is LayerKind.SOLIDFILL.

    5. SmartObjectLayer: This represents a Smart Object layer. Smart Objects are layers that contain image data from raster or vector images, and they preserve an image’s source content with all its original characteristics.

    6. AdjustmentLayer: This represents an adjustment layer. Adjustment layers are used to apply color and tonal adjustments without permanently changing the underlying pixel values.

    So if any of those layers appears on the canvas but don't have layers defined on them, the program will error out.

    opened by huchenlei 1
  • [Feature Request]: Controlnet masking for replacement Adobe Firefly Generative Fill

    [Feature Request]: Controlnet masking for replacement Adobe Firefly Generative Fill

    Here are some new control net features instructions. https://github.com/Mikubill/sd-webui-controlnet/discussions/1464 The above functionality shows how to use Controlnet to mimic Adobe Firefly Generative Fill.

    As a replacement for Adobe Firefly Generative Fill, how about adding the ability to send the same functionality as inpaint selection to text to image control net?

    Currently, Controlnet's masking capabilities are clearly limited to completely masking the desired area.

    opened by tinker495 1
  • When using the --hide-ui-dir-config parameter, [Send to Photopea] button is not displayed.

    When using the --hide-ui-dir-config parameter, [Send to Photopea] button is not displayed.

    In the photopea-bindings.js file at line 32, this code generates the [Send to Photopea] button:

    function createSendToPhotopeaButton(queryId, gallery) {
        const existingButton = gradioApp().querySelector(`#${queryId} button`);
        const newButton = existingButton.cloneNode(true);
        newButton.id = `${queryId}_open_in_photopea`;
        newButton.textContent = "Send to Photopea";
        newButton.addEventListener("click", () => openImageInPhotopea(gallery));
        gradioApp().querySelector(`#${queryId}`).appendChild(newButton);
    }
    

    It clones the first button inside #${queryId}, which is [Open images output directory] button.

    When using the --hide-ui-dir-config parameter, this button is hidden, and the cloned [Send to Photopea] button is also hidden.

    Set display to "flex" in createSendToPhotopeaButton should solve this problem:

    newButton.style.display = "flex";
    
    opened by Odls 1
  • Can't see the layers panel on a zoomed page :-)

    Can't see the layers panel on a zoomed page :-)

    My laptop's screen resolution is 2560x1440. So I need to load pages in FF in 133%. And I don't see the layers panel. Only the canvas and the left side of photopea. Even if I toggle page width resizing the window, Photopea will not resize its frame.

    If I reload my webui in 100% scale and open Photopea then all works fine. Even if I rescale it back in 133% - I see all the Photopea panels in 133%.

    Is it possible to change the frame width or something like that? :-)

    opened by ProgrammingLife 2
  • :bug: Fix export selected layer folder visibility issue

    :bug: Fix export selected layer folder visibility issue

    I found this bug when I am developing https://github.com/huchenlei/stable-diffusion-ps-pea.

    Steps to reproduce:

    • Set photopea in following state with a folder invisible, and select the folder or anything inside the folder. s1
    • Click send to inpaint mask. s2 You can see that the mask is not properly captured.

    For comparison, if you select a top level layer and perform the same action: s3 s4

    The issue is caused by original code does not account LayerSet's visibility. For an ArtLayer to be visible on canvas, all it's parent's visibility all need to be true.

    By default, add layer to add layer in current LayerSet if the activeLayer is a layerset or add a layer at the same level of the current active layer. So if we select the invisible folder layer, the new temp mask layer is added in the folder.

    This PR port my implemenetation of exportSelectedLayerOnly from https://github.com/huchenlei/stable-diffusion-ps-pea, with extra feature of specifying export format and having a callback function to select which layer to export.

    opened by huchenlei 0
  • bilingual-localization break 'Inpaint selection' button

    bilingual-localization break 'Inpaint selection' button

    My main language is Chinese, so I have been using [bilingual-localization] to display both Chinese and English.

    In the file photopea-bindings.js, at line 63, the [Inpaint selection] button get Inpaint tab using the following code:

    Array.from(allButtons).find(button => button.textContent === 'Inpaint upload ');
    

    However, [bilingual-localization] changes the value of textContent to '修復上傳 Inpaint upload ', which causes [Inpaint selection] can't find the Inpaint tab and therefore not work correctly.

    In my own copy, I have modified it to:

    Array.from(allButtons).find(button => button.textContent.endsWith('Inpaint upload '));
    

    This works fine for me, but there might be other users who did not using bilingual-localization but the original localization feature of SD-WebUI. This could result in the disappearance of the latter part of 'Inpaint upload ', leaving only the text in another language. Using 'endsWith' might not be a solution for them.

    Is there a more precise way to get Inpaint tab that avoids the localization break [Inpaint selection] functionality?

    opened by Odls 1
Owner
Yanko Oliveira
Gamedev. https://twitter.com/yankooliveira https://yanko.itch.io
Yanko Oliveira
This extension injects a button to the Google Drive WebUI.

This extension injects a button to the Google Drive WebUI. When clicking on it the current folder id is send to your gogdl-ng instance. It was developed and tested on the latest version of Mozilla Firefox and Chrome.

null 5 Jul 13, 2022
Easiest 1-click way to install and use Stable Diffusion on your own computer. Provides a browser UI for generating images from text prompts and images. Just enter your text prompt, and see the generated image.

Stable Diffusion UI Easiest way to install and use Stable Diffusion on your own computer. No dependencies or technical knowledge required. 1-click ins

null 3.5k Dec 30, 2022
A cross-platform desktop app with a nice interface to Stable Diffusion and others

GenerationQ GenerationQ (for "image generation queue") is a cross-platform desktop application (screens below) designed to provide a general purpose G

Weston C. Beecroft 25 Dec 28, 2022
a toy project to explore Stable Diffusion locally through a nodeJS server.

SD-explorer foreword this is a toy project to run the Stable Diffusion model locally. if you're after something more solid, I'd suggest you use WebUI

nicolas barradeau 18 Dec 18, 2022
🤗 A CLI for running Stable Diffusion locally via a REST API on an M1/M2 MacBook

Stable Diffusion REST API A CLI for running Stable Diffusion locally via a REST API on an M1/M2 MacBook Pre-requisites An M1/M2 MacBook Homebrew Pytho

Yuan Qing Lim 74 Dec 26, 2022
Minimalist UI for Stable Diffusion, built with SolidJS

Solid Diffusion Minimalist web-based interface for Stable Diffusion with persistant storage in the browser, built with SolidJS. This project is an alp

_nderscore 13 Nov 29, 2022
A web GUI for inpainting with Stable Diffusion using the Replicate API.

?? Inpainter A web GUI for inpainting with Stable Diffusion using the Replicate API. Try it out at inpainter.vercel.app cherries-oranges-bananas.mp4 H

Zeke Sikelianos 158 Dec 27, 2022
Concept Art/Prototyping faster with AIDA (AIDAdiffusion), "All-In-one" app for running Stable Diffusion on windows PC locally.

AIDAdiffusion Concept Art/Prototyping faster with ourbunka internal tool AIDA (AIDAdiffusion), "All-In-one" app for running Stable Diffusion on window

null 7 Nov 23, 2022
Backend for my Stable diffusion project(s)

Backend for my Stable diffusion project(s) Might be useful for others but at least it's useful for me. Only supports txt2img right now. Uses AUTOMATIC

Amotile 33 Dec 25, 2022
Portable, cross platform Stable Diffusion UI

FusionKit Releases FusionKit is a self-contained cross-platform app for generating images with Stable Diffusion. It leverages the InvokeAI project to

FusionKit 13 Dec 17, 2022
Meogic-tab-manager is an extensible, headless JavaScript tab manager framework.

MeogicTabManager English document MeogicTabManager是一个有可拓展性的、headless的JavaScript标签页管理框架。 MeogicTabManager旨在提供可自由组装页面框架、自定义页面组件、甚至覆盖框架自带事件响应的开发体验。 Meogi

meogic-tech 5 Oct 8, 2022
A Kernel Package that adds a tab to Discord settings where you can add and arrange custom code snippets.

Code Snippets A Kernel package (specifically for Discord) that adds a tab in settings where you can add and manage code snippets. Requires: https://gi

SwishyPlugs 6 Dec 14, 2022
Connect Web Integration illustrates the integration of Connect-Web in various JS frameworks and tooling

Connect Web Integration Connect Web Integration is a repository of example projects using Connect-Web with various JS frameworks and tooling. It provi

Buf 43 Dec 29, 2022
✏️ A new tab extension for convenient note-taking

MDTab Write quick notes in Markdown on any new tabs! Installation Right now MDTab has only been tested on Chrome (brave browser). You can install it f

Ian Huang (Shaoru) 8 Nov 11, 2022
A simple firefox/chrome extension adds Sci-Hub direct link access on publishing websites

Sci-Hub injector extension Supported sites PubMed Nature Science Direct Taylor & Francis Springer Link (article, book, chapter, protocol, reference wo

Dany 15 May 7, 2022
coc-pyright-tools is a coc-extension that adds its own functionality to coc-pyright for coc.nvim. Currently the "Inlay Hints", "CodeLens" and "Test Framework commands" feature is available.

coc-pyright-tools !!WARNING!! Inlay hints feature of coc-pyright-tools, have been ported to coc-pyright itself. https://github.com/fannheyward/coc-pyr

yaegassy 5 Aug 23, 2022
This provides an extension integration with Docker Desktop to run k9s quickly and easily through the Docker Desktop interface.

k9s extension for Docker Desktop This provides an extension integration with Docker Desktop to allow k9s quickly and easily through the Docker Desktop

James Spurin 14 Dec 16, 2022
VS Code extension that adds a red error squiggle to every word in your code.

Dumbisense Dumbisense is a VS Code extension that adds a red error squiggle to every word in your code, with an interesting error message and dino ima

Maggie Liu 9 Sep 3, 2022
Component oriented framework with Virtual dom (fast, stable, with tooling)

Bobril Main site bobril.com Changelog of npm version: https://github.com/Bobris/Bobril/blob/master/CHANGELOG.md Component oriented framework inspired

Boris Letocha 359 Dec 4, 2022