From 672dbda1cfddf1e0a18b8c2eb2afab1f70c71649 Mon Sep 17 00:00:00 2001 From: lein2023 <121925374+lein2023@users.noreply.github.com> Date: Tue, 23 May 2023 17:05:02 +0800 Subject: [PATCH] Modify the interface language to display as_ zh-CN Modify the interface language to display as_ zh-CN --- LICENSE.md | 42 +- README.md | 347 +- dialog_box.js | 156 +- enum.js | 114 +- helper.js | 240 +- index.html | 5886 +++++++++++++------------ index.js | 9496 ++++++++++++++++++++--------------------- install.py | 106 +- manifest.json | 10 +- outpaint.js | 1036 ++--- package.json | 62 +- psapi.js | 3196 +++++++------- requirements.txt | 50 +- sdapi_py_re.js | 1590 +++---- selection.js | 334 +- start_server_MacOS.sh | 34 +- thumbnail.js | 80 +- update_plugin.sh | 2 +- viewer.js | 1722 ++++---- 19 files changed, 12234 insertions(+), 12269 deletions(-) diff --git a/LICENSE.md b/LICENSE.md index 40defe74..0de47211 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,21 +1,21 @@ -MIT License - -Copyright (c) 2022 Abdullah Alfaraj - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +MIT License + +Copyright (c) 2022 Abdullah Alfaraj + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 01a96c9e..854bda11 100644 --- a/README.md +++ b/README.md @@ -1,188 +1,159 @@ - - -# Auto-Photoshop-StableDiffusion-Plugin -[![Become a Patron!](https://c5.patreon.com/external/logo/become_a_patron_button.png)](https://www.patreon.com/AbdullahAlfaraj) -[![discord badge]][discord link] - -[discord badge]: https://flat.badgen.net/discord/members/3mVEtrddXJ -[discord link]: https://discord.gg/3mVEtrddXJ - - - -With Auto-Photoshop-StableDiffusion-Plugin, you can directly use the capabilities of Automatic1111 Stable Diffusion in Photoshop without switching between programs. This allows you to easily use Stable Diffusion AI in a familiar environment. You can edit your Stable Diffusion image with all your favorite tools and save it right in Photoshop. - -# Table of Contents -- [Auto-Photoshop-StableDiffusion-Plugin](#auto-photoshop-stablediffusion-plugin) -- [Table of Contents](#table-of-contents) -- [Demo:](#demo) -- [Support Us On Patreon](#support-us-on-patreon) -- [How to Install](#how-to-install) - - [Method 1: One Click Installer](#method-1-one-click-installer) - - [Method 2: The Unzip Method](#method-2-the-unzip-method) - - [Method 3: The UXP Method (for Developers/Programmers Only)](#method-3-the-uxp-method-instruction-for-developers) - -- [FAQ and Known Issues](#faq-and-known-issues) - - [What Photoshop version do I need to run the plugin?](#what-photoshop-version-do-i-need-to-run-the-plugin) - - [Path Doesn't Exist](#path-doesnt-exist) - - [Plugin Load Failed](#plugin-load-failed) - - [No application are connected to the service](#no-application-are-connected-to-the-service) - - [Load command failed in App with ID PS and Version X.X.X](#load-command-failed-in-app-with-id-ps-and-version-xxx) - - [Exception in ASGI application / Expecting value: line 1 column 1](#exception-in-asgi-application--expecting-value-line-1-column-1) - - [No Generations and Plugin Server doesn't send messages. (Remote setup)](#no-generations-and-plugin-server-doesnt-send-messages-remote-setup) - -- [No GPU Options](#no-gpu-options) - - [Stable Horde](#stable-horde) - - [Colab](#colab) - -# Support Us On Patreon: -By supporting us on [Patreon](https://www.patreon.com/AbdullahAlfaraj), you’ll help us continue to develop and improve the Auto-Photoshop-StableDiffusion-Plugin, making it even easier for you to use Stable Diffusion AI in a familiar environment. As a supporter, you’ll have the opportunity to provide feedback and suggestions for future development. Plus, you’ll get early access to new features and tutorials, as well as exclusive art tutorials and tips from a professional artist. We’re passionate about making AI approachable to artists and with your help, we can continue to do just that. -# Auto-Photoshop-SD Backers and Sponsors: -**💎 Diamond:** -| [![Ronny Khalil](https://images.weserv.nl/?url=https://raw.githubusercontent.com/AbdullahAlfaraj/Auto-Photoshop-StableDiffusion-Plugin/206b56c911f67ede3ca3a934d0bce8c1d68a2113/docs/profile_image/A934E4F0-7778-47E9-A395-531BFF2E61F1_1_105_c.jpeg&h=80&w=80&fit=cover&mask=circle&maxage=7d)](https://ronnykhalil.com/) | ![zachary](https://ui-avatars.com/api/?background=random&color=fff&rounded=true&name=zachary) -|:---:|:---:| -| [Ronny Khalil](https://ronnykhalil.com/) | zachary - -**🥇 Gold:** -| ![Alex ](https://ui-avatars.com/api/?background=random&color=fff&rounded=true&name=Alex+) -|:---:| -| Alex - -**🥈 Silver:** -| ![Amith Thomas](https://ui-avatars.com/api/?background=random&color=fff&rounded=true&name=Amith+Thomas) | ![Olivier Lefebvre](https://ui-avatars.com/api/?background=random&color=fff&rounded=true&name=Olivier+Lefebvre) | ![xiao yuan](https://ui-avatars.com/api/?background=random&color=fff&rounded=true&name=xiao+yuan) | ![Ezra Blake](https://ui-avatars.com/api/?background=random&color=fff&rounded=true&name=Ezra+Blake) -|:---:|:---:|:---:|:---:| -| Amith Thomas | Olivier Lefebvre | xiao yuan | Ezra Blake - -**🥉 Copper:** -| ![Sebastian Karbowniczek](https://ui-avatars.com/api/?background=random&color=fff&rounded=true&name=Sebastian+Karbowniczek) | ![Arthur Liu](https://ui-avatars.com/api/?background=random&color=fff&rounded=true&name=Arthur+Liu) -|:---:|:---:| -| Sebastian Karbowniczek | Arthur Liu - - - - - - - - -# How To Install: -Use method 1 or 2 if you are an Artist -use method 3 if you are a Developer/Programmer - - -# Method 1: One Click Installer - -1) Download the [.ccx](https://github.com/AbdullahAlfaraj/Auto-Photoshop-StableDiffusion-Plugin/releases/latest) file -2) run the ccx file . that's all. you will be able to use all of stable diffusion modes (txt2img, img2img, inpainting and outpainting), check the [tutorials](https://github.com/AbdullahAlfaraj/Auto-Photoshop-StableDiffusion-Plugin/wiki) section to master the tool. - -![install_plugin_1](https://user-images.githubusercontent.com/7842232/217213943-3e2a588d-3ed8-4757-ba69-9846b55a1b36.gif) - - -3) (optional step) Install the Auto-Photoshop-SD Extension from Automatic1111. the extension will allow you to use the smart masking and image search features - - a) Copy Auto-Photoshop plugin url -![copy_githup_url_2](https://user-images.githubusercontent.com/7842232/217213998-367873ce-2c09-4c42-a5fa-0044415e3908.gif) - -- b) Paste the url in auto1111's extension tab and click install - -![install_extension_3](https://user-images.githubusercontent.com/7842232/217214062-4c2fef9e-8d49-46a0-aa3b-80c4975f8a70.gif) - -- c) Make sure the Auto-Photoshop plugin is listed, then click "Apply and Restart UI" - -![apply_and_restart_4](https://user-images.githubusercontent.com/7842232/217214116-2e30d7b8-aeb6-44df-aff3-4788a56cd800.gif) - - - -# Method 2: The Unzip Method -1) Download the [.zip](https://github.com/AbdullahAlfaraj/Auto-Photoshop-StableDiffusion-Plugin/releases/latest) file -2) Unzip it in a folder with the same name -3) move the unzipped folder to the Photoshop Plugin folder -4) (optional step) Install the Auto-Photoshop-SD Extension from Automatic1111. the extension will allow you to use the smart masking and image search features -![image](https://user-images.githubusercontent.com/7842232/223751539-1a3013aa-aa1d-4058-87ae-e8b3fdfc5ec8.png) - - - -# Method 3: The UXP method (Instruction for Developers): -For artists we recommend you use [the one click installer](#one-click-installer). If you are a developer Watch the any of these videos or follow the instruction bellow. - - - - - -For artists we recommend you use [the one click installer](#one-click-installer) -## First time running the plugin (local Automatic1111): -1) download the plugin: -``` -git clone https://github.com/AbdullahAlfaraj/Auto-Photoshop-StableDiffusion-Plugin.git -``` -2) run "start_server.bat" inside "Auto-Photoshop-StableDiffusion-Plugin" directory -3) go to where you have [automatic1111](https://github.com/AUTOMATIC1111/stable-diffusion-webui) installed. -Edit the "webui-user.bat" in automatic1111 - change this line -``` -set COMMANDLINE_ARGS= -``` -to -``` -set COMMANDLINE_ARGS= --api -``` -that will allow the plugin to communicate with the automatic1111 project. After saving close the "webui-user.bat" file and run it normally. - -4) run photoshop. go to edit -> prefrences -> plugins - 1) make sure you check "Enable Developer Mode" checkbox -5) install "Adobe UXP Developer Tool" from here [Installation (adobe.com)](https://developer.adobe.com/photoshop/uxp/devtool/installation/) - this tool will add the plugin into photoshop -6) run Adobe UXP Developer Tool and click on "Add Plugin" button in the top right. Navigate to where you have "Auto-Photoshop-StableDiffusion-Plugin" folder and open "manifest.json" -7) select the plugin and click on Actions -> Load Selected -that's it. - -## First time running the plugin (remote Automatic1111): -__The remote webui must also have `--api` set in `COMMANDLINE_ARGS`. You can check if api access is enabled by appending "/docs#" to the end of the url. If the documentation includes `/sdapi/v1/samplers` then api access is enabled.__ - -1) download the plugin: -``` -git clone https://github.com/AbdullahAlfaraj/Auto-Photoshop-StableDiffusion-Plugin.git -``` -1) edit [start_server.bat](start_server.bat) (or start_server.sh if on linux) to point to the remote installation of Automatic1111 -2) run "start_server.bat" inside "Auto-Photoshop-StableDiffusion-Plugin" directory -3) run photoshop. go to edit -> prefrences -> plugins - 1) make sure you check "Enable Developer Mode" checkbox -4) install "Adobe UXP Developer Tool" from here [Installation (adobe.com)](https://developer.adobe.com/photoshop/uxp/devtool/installation/) - this tool will add the plugin into photoshop -5) run Adobe UXP Developer Tool and click on "Add Plugin" button in the top right. Navigate to where you have "Auto-Photoshop-StableDiffusion-Plugin" folder and open "manifest.json" -6) select the plugin and click on Actions -> Load Selected -that's it. - - - - - - -# Demo: -[![Click Here to Watch Demo](https://i3.ytimg.com/vi/VL_gbQai79E/maxresdefault.jpg)](https://youtu.be/VL_gbQai79E "Stable diffusion AI Photoshop Plugin Free and Open Source") - - -# FAQ and Known Issues -## What Photoshop version do I need to run the plugin? -The minimum Photoshop version that the plugin supports is Photoshop v24 - -## Plugin Load Failed -There are a few issues that can result in this error, please follow the instructions for the corresponding error message in the UDT logs - -### No application are connected to the service -This error occurs when Photoshop is not started before the plugin is attempted to be loaded. Simply start photoshop then restart UXP and load the plugin - - -## Exception in ASGI application / Expecting value: line 1 column 1 -This error occurs due to mismatched expectations between the plugin and the Automatic1111 backend. -It can be solved by both updating the version of the Automatic111 backend to the latest verion, and making sure "Save text information about generation parameters as chunks to png files" setting is enabled within the UI. - -## No Generations and Plugin Server doesn't send messages. (Remote setup) -This error occurs when the remote server does not have the api enabled. You can verify this by attempting to go to the URL you access the webui at and appending "/docs#" to the end of the url. If you have permissions, make relaunch the remote instance with the "--api" flag. - -# No GPU Options: -we provide two options to use the auto-photoshp plugin without GPU. -## Stable Horde -This is an awesome free crowdsourced distributed cluster of Stable Diffusion workers. If you like this service, consider joining the horde yourself! -the horde is enabled completely by the generosity of volunteers so make sure you don't overwhelm the service and help join the cause if you can. -read more on their [github page](https://github.com/db0/AI-Horde) -## Colab: -we link to this [Colab](https://colab.research.google.com/drive/1nbcx_WOneRmYv9idBO33pN5CbxXrqZHu?usp=sharing#scrollTo=Y4ebYsPqTrGb) directly inside plugin find it in the settings tab. you only need to run it. no need to change any of the settings. copy the gradio.live url the colab will generate and paste it into ```sd url``` field in the settings tab. + + +# Auto-Photoshop-StableDiffusion-Plugin +[![Become a Patron!](https://c5.patreon.com/external/logo/become_a_patron_button.png)](https://www.patreon.com/AbdullahAlfaraj) +[![discord badge]][discord link] + +[discord badge]: https://flat.badgen.net/discord/members/3mVEtrddXJ +[discord link]: https://discord.gg/3mVEtrddXJ + + + +With Auto-Photoshop-StableDiffusion-Plugin, you can directly use the capabilities of Automatic1111 Stable Diffusion in Photoshop without switching between programs. This allows you to easily use Stable Diffusion AI in a familiar environment. You can edit your Stable Diffusion image with all your favorite tools and save it right in Photoshop. + +# Table of Contents +- [Auto-Photoshop-StableDiffusion-Plugin](#auto-photoshop-stablediffusion-plugin) +- [Table of Contents](#table-of-contents) +- [Demo:](#demo) +- [Support Us On Patreon](#support-us-on-patreon) +- [How to Install](#how-to-install) + - [Method 1: One Click Installer](#method-1-one-click-installer) + - [Method 2: The Unzip Method](#method-2-the-unzip-method) + - [Method 3: The UXP Method (for Developers/Programmers Only)](#method-3-the-uxp-method-instruction-for-developers) + +- [FAQ and Known Issues](#faq-and-known-issues) + - [What Photoshop version do I need to run the plugin?](#what-photoshop-version-do-i-need-to-run-the-plugin) + - [Path Doesn't Exist](#path-doesnt-exist) + - [Plugin Load Failed](#plugin-load-failed) + - [No application are connected to the service](#no-application-are-connected-to-the-service) + - [Load command failed in App with ID PS and Version X.X.X](#load-command-failed-in-app-with-id-ps-and-version-xxx) + - [Exception in ASGI application / Expecting value: line 1 column 1](#exception-in-asgi-application--expecting-value-line-1-column-1) + - [No Generations and Plugin Server doesn't send messages. (Remote setup)](#no-generations-and-plugin-server-doesnt-send-messages-remote-setup) + +- [No GPU Options](#no-gpu-options) + - [Stable Horde](#stable-horde) + - [Colab](#colab) + +# Support Us On Patreon: +By supporting us on [Patreon](https://www.patreon.com/AbdullahAlfaraj), you’ll help us continue to develop and improve the Auto-Photoshop-StableDiffusion-Plugin, making it even easier for you to use Stable Diffusion AI in a familiar environment. As a supporter, you’ll have the opportunity to provide feedback and suggestions for future development. Plus, you’ll get early access to new features and tutorials, as well as exclusive art tutorials and tips from a professional artist. We’re passionate about making AI approachable to artists and with your help, we can continue to do just that. +# How To Install: +Use method 1 or 2 if you are an Artist +use method 3 if you are a Developer/Programmer + + +# Method 1: One Click Installer + +1) Download the [.ccx](https://github.com/AbdullahAlfaraj/Auto-Photoshop-StableDiffusion-Plugin/releases/latest) file +2) run the ccx file . that's all. you will be able to use all of stable diffusion modes (txt2img, img2img, inpainting and outpainting), check the [tutorials](https://github.com/AbdullahAlfaraj/Auto-Photoshop-StableDiffusion-Plugin/wiki) section to master the tool. + +![install_plugin_1](https://user-images.githubusercontent.com/7842232/217213943-3e2a588d-3ed8-4757-ba69-9846b55a1b36.gif) + + +3) (optional step) Install the Auto-Photoshop-SD Extension from Automatic1111. the extension will allow you to use the smart masking and image search features + - a) Copy Auto-Photoshop plugin url +![copy_githup_url_2](https://user-images.githubusercontent.com/7842232/217213998-367873ce-2c09-4c42-a5fa-0044415e3908.gif) + +- b) Paste the url in auto1111's extension tab and click install + +![install_extension_3](https://user-images.githubusercontent.com/7842232/217214062-4c2fef9e-8d49-46a0-aa3b-80c4975f8a70.gif) + +- c) Make sure the Auto-Photoshop plugin is listed, then click "Apply and Restart UI" + +![apply_and_restart_4](https://user-images.githubusercontent.com/7842232/217214116-2e30d7b8-aeb6-44df-aff3-4788a56cd800.gif) + + + +# Method 2: The Unzip Method +1) Download the [.zip](https://github.com/AbdullahAlfaraj/Auto-Photoshop-StableDiffusion-Plugin/releases/latest) file +2) Unzip it in a folder with the same name +3) move the unzipped folder to the Photoshop Plugin folder +4) (optional step) Install the Auto-Photoshop-SD Extension from Automatic1111. the extension will allow you to use the smart masking and image search features +![image](https://user-images.githubusercontent.com/7842232/223751539-1a3013aa-aa1d-4058-87ae-e8b3fdfc5ec8.png) + + + +# Method 3: The UXP method (Instruction for Developers): +For artists we recommend you use [the one click installer](#one-click-installer). If you are a developer Watch the any of these videos or follow the instruction bellow. + + + + + +For artists we recommend you use [the one click installer](#one-click-installer) +## First time running the plugin (local Automatic1111): +1) download the plugin: +``` +git clone https://github.com/AbdullahAlfaraj/Auto-Photoshop-StableDiffusion-Plugin.git +``` +2) run "start_server.bat" inside "Auto-Photoshop-StableDiffusion-Plugin" directory +3) go to where you have [automatic1111](https://github.com/AUTOMATIC1111/stable-diffusion-webui) installed. +Edit the "webui-user.bat" in automatic1111 + change this line +``` +set COMMANDLINE_ARGS= +``` +to +``` +set COMMANDLINE_ARGS= --api +``` +that will allow the plugin to communicate with the automatic1111 project. After saving close the "webui-user.bat" file and run it normally. + +4) run photoshop. go to edit -> prefrences -> plugins + 1) make sure you check "Enable Developer Mode" checkbox +5) install "Adobe UXP Developer Tool" from here [Installation (adobe.com)](https://developer.adobe.com/photoshop/uxp/devtool/installation/) + this tool will add the plugin into photoshop +6) run Adobe UXP Developer Tool and click on "Add Plugin" button in the top right. Navigate to where you have "Auto-Photoshop-StableDiffusion-Plugin" folder and open "manifest.json" +7) select the plugin and click on Actions -> Load Selected +that's it. + +## First time running the plugin (remote Automatic1111): +__The remote webui must also have `--api` set in `COMMANDLINE_ARGS`. You can check if api access is enabled by appending "/docs#" to the end of the url. If the documentation includes `/sdapi/v1/samplers` then api access is enabled.__ + +1) download the plugin: +``` +git clone https://github.com/AbdullahAlfaraj/Auto-Photoshop-StableDiffusion-Plugin.git +``` +1) edit [start_server.bat](start_server.bat) (or start_server.sh if on linux) to point to the remote installation of Automatic1111 +2) run "start_server.bat" inside "Auto-Photoshop-StableDiffusion-Plugin" directory +3) run photoshop. go to edit -> prefrences -> plugins + 1) make sure you check "Enable Developer Mode" checkbox +4) install "Adobe UXP Developer Tool" from here [Installation (adobe.com)](https://developer.adobe.com/photoshop/uxp/devtool/installation/) + this tool will add the plugin into photoshop +5) run Adobe UXP Developer Tool and click on "Add Plugin" button in the top right. Navigate to where you have "Auto-Photoshop-StableDiffusion-Plugin" folder and open "manifest.json" +6) select the plugin and click on Actions -> Load Selected +that's it. + + + + + + +# Demo: +[![Click Here to Watch Demo](https://i3.ytimg.com/vi/VL_gbQai79E/maxresdefault.jpg)](https://youtu.be/VL_gbQai79E "Stable diffusion AI Photoshop Plugin Free and Open Source") + +# FAQ and Known Issues +## What Photoshop version do I need to run the plugin? +The minimum Photoshop version that the plugin supports is Photoshop v24 + +## Plugin Load Failed +There are a few issues that can result in this error, please follow the instructions for the corresponding error message in the UDT logs + +### No application are connected to the service +This error occurs when Photoshop is not started before the plugin is attempted to be loaded. Simply start photoshop then restart UXP and load the plugin + + +## Exception in ASGI application / Expecting value: line 1 column 1 +This error occurs due to mismatched expectations between the plugin and the Automatic1111 backend. +It can be solved by both updating the version of the Automatic111 backend to the latest verion, and making sure "Save text information about generation parameters as chunks to png files" setting is enabled within the UI. + +## No Generations and Plugin Server doesn't send messages. (Remote setup) +This error occurs when the remote server does not have the api enabled. You can verify this by attempting to go to the URL you access the webui at and appending "/docs#" to the end of the url. If you have permissions, make relaunch the remote instance with the "--api" flag. + +# No GPU Options: +we provide two options to use the auto-photoshp plugin without GPU. +## Stable Horde +This is an awesome free crowdsourced distributed cluster of Stable Diffusion workers. If you like this service, consider joining the horde yourself! +the horde is enabled completely by the generosity of volunteers so make sure you don't overwhelm the service and help join the cause if you can. +read more on their [github page](https://github.com/db0/AI-Horde) +## Colab: +we link to this [Colab](https://colab.research.google.com/drive/1nbcx_WOneRmYv9idBO33pN5CbxXrqZHu?usp=sharing#scrollTo=Y4ebYsPqTrGb) directly inside plugin find it in the settings tab. you only need to run it. no need to change any of the settings. copy the gradio.live url the colab will generate and paste it into ```sd url``` field in the settings tab. diff --git a/dialog_box.js b/dialog_box.js index 1dc465fb..329db6f0 100644 --- a/dialog_box.js +++ b/dialog_box.js @@ -1,78 +1,78 @@ -async function prompt( - heading, - body, - buttons = ['Cancel', 'Ok'], - options = { title: heading, size: { width: 360, height: 280 } } -) { - const [dlgEl, formEl, headingEl, dividerEl, bodyEl, footerEl] = [ - 'dialog', - 'form', - 'sp-heading', - 'sp-divider', - 'sp-body', - 'footer', - ].map((tag) => document.createElement(tag)) - ;[headingEl, dividerEl, bodyEl, footerEl].forEach((el) => { - el.style.margin = '6px' - el.style.width = 'calc(100% - 12px)' - }) - - formEl.setAttribute('method', 'dialog') - formEl.addEventListener('submit', () => dlgEl.close()) - - footerEl.style.marginTop = '26px' - - dividerEl.setAttribute('size', 'large') - - headingEl.textContent = heading - - bodyEl.textContent = body - - buttons.forEach((btnText, idx) => { - const btnEl = document.createElement('sp-button') - btnEl.setAttribute( - 'variant', - idx === buttons.length - 1 ? btnText.variant || 'cta' : 'secondary' - ) - if (idx === buttons.length - 1) - btnEl.setAttribute('autofocus', 'autofocus') - if (idx < buttons.length - 1) btnEl.setAttribute('quiet') - btnEl.textContent = btnText.text || btnText - btnEl.style.marginLeft = '12px' - btnEl.addEventListener('click', () => - dlgEl.close(btnText.text || btnText) - ) - footerEl.appendChild(btnEl) - }) - ;[headingEl, dividerEl, bodyEl, footerEl].forEach((el) => - formEl.appendChild(el) - ) - dlgEl.appendChild(formEl) - document.body.appendChild(dlgEl) - - return dlgEl.uxpShowModal(options) -} - -// const r1 = await prompt( -// 'Upload Large File', -// 'This is a large file (over 100MB) -- it may take a few moments to upload.', -// ['Skip', 'Upload'] -// ) -// if ((r1 || 'Upload') !== 'Upload') { -// /* cancelled or No */ -// } else { -// /* Yes */ -// } - -// const r2 = await prompt( -// 'Delete File', -// 'Are you sure you wish to delete this file? This action cannot be undone.', -// ['Cancel', { variant: 'warning', text: 'Delete' }] -// ) -// if (r2 !== 'Delete') { -// /* nope, don't do it! */ -// } else { -// /* Do the delete */ -// } - -module.exports = { prompt } +async function prompt( + heading, + body, + buttons = ['Cancel', 'Ok'], + options = { title: heading, size: { width: 360, height: 280 } } +) { + const [dlgEl, formEl, headingEl, dividerEl, bodyEl, footerEl] = [ + 'dialog', + 'form', + 'sp-heading', + 'sp-divider', + 'sp-body', + 'footer', + ].map((tag) => document.createElement(tag)) + ;[headingEl, dividerEl, bodyEl, footerEl].forEach((el) => { + el.style.margin = '6px' + el.style.width = 'calc(100% - 12px)' + }) + + formEl.setAttribute('method', 'dialog') + formEl.addEventListener('submit', () => dlgEl.close()) + + footerEl.style.marginTop = '26px' + + dividerEl.setAttribute('size', 'large') + + headingEl.textContent = heading + + bodyEl.textContent = body + + buttons.forEach((btnText, idx) => { + const btnEl = document.createElement('sp-button') + btnEl.setAttribute( + 'variant', + idx === buttons.length - 1 ? btnText.variant || 'cta' : 'secondary' + ) + if (idx === buttons.length - 1) + btnEl.setAttribute('autofocus', 'autofocus') + if (idx < buttons.length - 1) btnEl.setAttribute('quiet') + btnEl.textContent = btnText.text || btnText + btnEl.style.marginLeft = '12px' + btnEl.addEventListener('click', () => + dlgEl.close(btnText.text || btnText) + ) + footerEl.appendChild(btnEl) + }) + ;[headingEl, dividerEl, bodyEl, footerEl].forEach((el) => + formEl.appendChild(el) + ) + dlgEl.appendChild(formEl) + document.body.appendChild(dlgEl) + + return dlgEl.uxpShowModal(options) +} + +// const r1 = await prompt( +// 'Upload Large File', +// 'This is a large file (over 100MB) -- it may take a few moments to upload.', +// ['Skip', 'Upload'] +// ) +// if ((r1 || 'Upload') !== 'Upload') { +// /* cancelled or No */ +// } else { +// /* Yes */ +// } + +// const r2 = await prompt( +// 'Delete File', +// 'Are you sure you wish to delete this file? This action cannot be undone.', +// ['Cancel', { variant: 'warning', text: 'Delete' }] +// ) +// if (r2 !== 'Delete') { +// /* nope, don't do it! */ +// } else { +// /* Do the delete */ +// } + +module.exports = { prompt } diff --git a/enum.js b/enum.js index 1cf996a2..17f04907 100644 --- a/enum.js +++ b/enum.js @@ -1,57 +1,57 @@ -const clickTypeEnum = { - Click: 'click', - ShiftClick: 'shift_click', - AltClick: 'alt_click', - SecondClick: 'second_click', //when we click a thumbnail that is active/ has orange border -} -const generationModeEnum = { - Txt2Img: 'txt2img', - Img2Img: 'img2img', - Inpaint: 'inpaint', - Outpaint: 'outpaint', - Upscale: 'upscale', -} - -const AutomaticStatusEnum = { - NoApi: 'no_api', - Offline: 'offline', - RunningNoApi: 'running_no_api', - RunningWithApi: 'running_with_api', -} - -const ViewerObjectTypeEnum = { - OutputImage: 'output_image', - InitImage: 'init_image', - MaskImage: 'mask_image', -} - -const RequestStateEnum = { - Generating: 'generating', // in the generation process - Interrupted: 'interrupted', // canceled/ interrupted - Finished: 'finished', // finished generating -} -const DocumentTypeEnum = { - NoBackground: 'no_background', - ImageBackground: 'image_background', - SolidBackground: 'solid_background', - ArtBoard: 'artboard', -} -const BackgroundHistoryEnum = { - CorrectBackground: 'correct_background', - NoBackground: 'no_background', -} - -const PresetTypeEnum = { - SDPreset: 'sd_preset', - ControlNetPreset: 'controlnet_preset', -} -module.exports = { - clickTypeEnum, - generationModeEnum, - AutomaticStatusEnum, - ViewerObjectTypeEnum, - RequestStateEnum, - DocumentTypeEnum, - BackgroundHistoryEnum, - PresetTypeEnum, -} +const clickTypeEnum = { + Click: 'click', + ShiftClick: 'shift_click', + AltClick: 'alt_click', + SecondClick: 'second_click', //when we click a thumbnail that is active/ has orange border +} +const generationModeEnum = { + Txt2Img: 'txt2img', + Img2Img: 'img2img', + Inpaint: 'inpaint', + Outpaint: 'outpaint', + Upscale: 'upscale', +} + +const AutomaticStatusEnum = { + NoApi: 'no_api', + Offline: 'offline', + RunningNoApi: 'running_no_api', + RunningWithApi: 'running_with_api', +} + +const ViewerObjectTypeEnum = { + OutputImage: 'output_image', + InitImage: 'init_image', + MaskImage: 'mask_image', +} + +const RequestStateEnum = { + Generating: 'generating', // in the generation process + Interrupted: 'interrupted', // canceled/ interrupted + Finished: 'finished', // finished generating +} +const DocumentTypeEnum = { + NoBackground: 'no_background', + ImageBackground: 'image_background', + SolidBackground: 'solid_background', + ArtBoard: 'artboard', +} +const BackgroundHistoryEnum = { + CorrectBackground: 'correct_background', + NoBackground: 'no_background', +} + +const PresetTypeEnum = { + SDPreset: 'sd_preset', + ControlNetPreset: 'controlnet_preset', +} +module.exports = { + clickTypeEnum, + generationModeEnum, + AutomaticStatusEnum, + ViewerObjectTypeEnum, + RequestStateEnum, + DocumentTypeEnum, + BackgroundHistoryEnum, + PresetTypeEnum, +} diff --git a/helper.js b/helper.js index 58993d84..2fc5f2f3 100644 --- a/helper.js +++ b/helper.js @@ -1,120 +1,120 @@ -const { unselectActiveLayers } = require('./psapi') - -const app = window.require('photoshop').app - -function getActiveLayer() { - let activeLayers = app.activeDocument.activeLayers - // console.dir(getSize()) - for (const layer of activeLayers) { - console.dir({ layer }) - const name = layer.name - console.dir({ name }) - let layer_size = getLayerSize(layer) - console.dir({ layer_size }) - } - - return activeLayers[0] -} - -function getSize() { - let doc = app.activeDocument - return { height: doc.height, width: doc.width } -} - -const { batchPlay } = require('photoshop').action -const { executeAsModal } = require('photoshop').core - -async function reselectBatchPlay(selectionInfo) { - const result = await batchPlay( - [ - { - _obj: 'set', - _target: [ - { - _ref: 'channel', - _property: 'selection', - }, - ], - to: { - _obj: 'rectangle', - top: { - _unit: 'pixelsUnit', - _value: selectionInfo.top, - }, - left: { - _unit: 'pixelsUnit', - _value: selectionInfo.left, - }, - bottom: { - _unit: 'pixelsUnit', - _value: selectionInfo.bottom, - }, - right: { - _unit: 'pixelsUnit', - _value: selectionInfo.right, - }, - }, - _options: { - dialogOptions: 'dontDisplay', - }, - }, - ], - { - synchronousExecution: true, - modalBehavior: 'execute', - } - ) -} - -async function reselect(selectionInfo) { - await executeAsModal( - async () => { - reselectBatchPlay(selectionInfo) - }, - { commandName: 'reselect' } - ) -} - -//unselect the rectangular marquee selection area -async function unSelect() { - const batchPlay = require('photoshop').action.batchPlay - - const result = await batchPlay( - [ - { - _obj: 'set', - _target: [ - { - _ref: 'channel', - _property: 'selection', - }, - ], - to: { - _enum: 'ordinal', - _value: 'none', - }, - _options: { - dialogOptions: 'dontDisplay', - }, - }, - ], - { - synchronousExecution: true, - modalBehavior: 'execute', - } - ) - - return result -} - -/** - * Convert 1d index to 2d array - * @param {number} index sequential index - * @param {number} width width of 2d array - * @returns {number[]} [x,y] - */ -function indexToXY(index, width) { - return [index % width, Math.floor(index / width)] -} - -module.exports = {} +const { unselectActiveLayers } = require('./psapi') + +const app = window.require('photoshop').app + +function getActiveLayer() { + let activeLayers = app.activeDocument.activeLayers + // console.dir(getSize()) + for (const layer of activeLayers) { + console.dir({ layer }) + const name = layer.name + console.dir({ name }) + let layer_size = getLayerSize(layer) + console.dir({ layer_size }) + } + + return activeLayers[0] +} + +function getSize() { + let doc = app.activeDocument + return { height: doc.height, width: doc.width } +} + +const { batchPlay } = require('photoshop').action +const { executeAsModal } = require('photoshop').core + +async function reselectBatchPlay(selectionInfo) { + const result = await batchPlay( + [ + { + _obj: 'set', + _target: [ + { + _ref: 'channel', + _property: 'selection', + }, + ], + to: { + _obj: 'rectangle', + top: { + _unit: 'pixelsUnit', + _value: selectionInfo.top, + }, + left: { + _unit: 'pixelsUnit', + _value: selectionInfo.left, + }, + bottom: { + _unit: 'pixelsUnit', + _value: selectionInfo.bottom, + }, + right: { + _unit: 'pixelsUnit', + _value: selectionInfo.right, + }, + }, + _options: { + dialogOptions: 'dontDisplay', + }, + }, + ], + { + synchronousExecution: true, + modalBehavior: 'execute', + } + ) +} + +async function reselect(selectionInfo) { + await executeAsModal( + async () => { + reselectBatchPlay(selectionInfo) + }, + { commandName: 'reselect' } + ) +} + +//unselect the rectangular marquee selection area +async function unSelect() { + const batchPlay = require('photoshop').action.batchPlay + + const result = await batchPlay( + [ + { + _obj: 'set', + _target: [ + { + _ref: 'channel', + _property: 'selection', + }, + ], + to: { + _enum: 'ordinal', + _value: 'none', + }, + _options: { + dialogOptions: 'dontDisplay', + }, + }, + ], + { + synchronousExecution: true, + modalBehavior: 'execute', + } + ) + + return result +} + +/** + * Convert 1d index to 2d array + * @param {number} index sequential index + * @param {number} width width of 2d array + * @returns {number[]} [x,y] + */ +function indexToXY(index, width) { + return [index % width, Math.floor(index / width)] +} + +module.exports = {} diff --git a/index.html b/index.html index a3a60f7c..51ac8d49 100644 --- a/index.html +++ b/index.html @@ -1,2945 +1,2941 @@ - - -
- - - - - - - - - -
-
-
-
-
-
-
-
-
-
-
- |
-
-
-
-
-
-
-
-
-
- |
-
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+ |
+