fix formatting again
parent
37dd14a2fa
commit
ac31403f9e
|
|
@ -3,4 +3,4 @@
|
|||
"tabWidth": 4,
|
||||
"semi": false,
|
||||
"singleQuote": true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,53 +1,56 @@
|
|||
async function prompt(
|
||||
heading,
|
||||
body,
|
||||
buttons = ["Cancel", "Ok"],
|
||||
options = { title: heading, size: { width: 360, height: 280 } }
|
||||
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)"
|
||||
})
|
||||
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())
|
||||
formEl.setAttribute('method', 'dialog')
|
||||
formEl.addEventListener('submit', () => dlgEl.close())
|
||||
|
||||
footerEl.style.marginTop = "26px"
|
||||
footerEl.style.marginTop = '26px'
|
||||
|
||||
dividerEl.setAttribute("size", "large")
|
||||
dividerEl.setAttribute('size', 'large')
|
||||
|
||||
headingEl.textContent = heading
|
||||
headingEl.textContent = heading
|
||||
|
||||
bodyEl.textContent = body
|
||||
bodyEl.textContent = body
|
||||
|
||||
buttons.forEach((btnText, idx) => {
|
||||
const btnEl = document.createElement("sp-button")
|
||||
btnEl.setAttribute(
|
||||
"variant",
|
||||
idx === buttons.length - 1 ? btnText.variant || "cta" : "secondary"
|
||||
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)
|
||||
)
|
||||
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)
|
||||
dlgEl.appendChild(formEl)
|
||||
document.body.appendChild(dlgEl)
|
||||
|
||||
return dlgEl.uxpShowModal(options)
|
||||
return dlgEl.uxpShowModal(options)
|
||||
}
|
||||
|
||||
// const r1 = await prompt(
|
||||
|
|
|
|||
310
export_png.js
310
export_png.js
|
|
@ -1,121 +1,121 @@
|
|||
const { executeAsModal } = require("photoshop").core
|
||||
const storage = require("uxp").storage
|
||||
const { executeAsModal } = require('photoshop').core
|
||||
const storage = require('uxp').storage
|
||||
const fs = storage.localFileSystem
|
||||
const formats = require("uxp").storage.formats
|
||||
const formats = require('uxp').storage.formats
|
||||
async function exportPngCommand() {
|
||||
const batchPlay = require("photoshop").action.batchPlay
|
||||
// const result = await batchPlay { _obj: “exportSelectionAsFileTypePressed”}
|
||||
const batchPlay = require('photoshop').action.batchPlay
|
||||
// const result = await batchPlay { _obj: “exportSelectionAsFileTypePressed”}
|
||||
|
||||
// const destFolder = (await storage.localFileSystem.getDataFolder()).nativePath;
|
||||
const storage = require("uxp").storage
|
||||
const fs = storage.localFileSystem
|
||||
// const destFolder = (await storage.localFileSystem.getDataFolder()).nativePath;
|
||||
const storage = require('uxp').storage
|
||||
const fs = storage.localFileSystem
|
||||
|
||||
let pluginFolder = await fs.getPluginFolder()
|
||||
// await fs.getFolder("./init_images")
|
||||
let init_images_dir = await pluginFolder.getEntry(
|
||||
"./server/python_server/init_images"
|
||||
)
|
||||
let pluginFolder = await fs.getPluginFolder()
|
||||
// await fs.getFolder("./init_images")
|
||||
let init_images_dir = await pluginFolder.getEntry(
|
||||
'./server/python_server/init_images'
|
||||
)
|
||||
|
||||
const exportCommand = {
|
||||
_obj: "exportSelectionAsFileTypePressed",
|
||||
_target: { _ref: "layer", _enum: "ordinal", _value: "targetEnum" },
|
||||
fileType: "png",
|
||||
quality: 32,
|
||||
metadata: 0,
|
||||
destFolder: init_images_dir.nativePath,
|
||||
sRGB: true,
|
||||
openWindow: false,
|
||||
_options: { dialogOptions: "dontDisplay" },
|
||||
}
|
||||
const result = await batchPlay([exportCommand], {
|
||||
synchronousExecution: true,
|
||||
modalBehavior: "execute",
|
||||
})
|
||||
const exportCommand = {
|
||||
_obj: 'exportSelectionAsFileTypePressed',
|
||||
_target: { _ref: 'layer', _enum: 'ordinal', _value: 'targetEnum' },
|
||||
fileType: 'png',
|
||||
quality: 32,
|
||||
metadata: 0,
|
||||
destFolder: init_images_dir.nativePath,
|
||||
sRGB: true,
|
||||
openWindow: false,
|
||||
_options: { dialogOptions: 'dontDisplay' },
|
||||
}
|
||||
const result = await batchPlay([exportCommand], {
|
||||
synchronousExecution: true,
|
||||
modalBehavior: 'execute',
|
||||
})
|
||||
|
||||
return result
|
||||
return result
|
||||
}
|
||||
async function exportPng() {
|
||||
const { executeAsModal } = require("photoshop").core
|
||||
try {
|
||||
await executeAsModal(exportPngCommand)
|
||||
} catch (e) {
|
||||
console.warn("exportPng error:", e)
|
||||
}
|
||||
const { executeAsModal } = require('photoshop').core
|
||||
try {
|
||||
await executeAsModal(exportPngCommand)
|
||||
} catch (e) {
|
||||
console.warn('exportPng error:', e)
|
||||
}
|
||||
}
|
||||
|
||||
const readPng = async (image_name) => {
|
||||
// image_name = 'test.png'
|
||||
try {
|
||||
await executeAsModal(
|
||||
async (control) => {
|
||||
// const tempFolder = await fs.getTemporaryFolder() ;
|
||||
const pluginFolder = await fs.getPluginFolder()
|
||||
// image_name = 'test.png'
|
||||
try {
|
||||
await executeAsModal(
|
||||
async (control) => {
|
||||
// const tempFolder = await fs.getTemporaryFolder() ;
|
||||
const pluginFolder = await fs.getPluginFolder()
|
||||
|
||||
let init_images_dir = await pluginFolder.getEntry(
|
||||
"./server/python_server/init_images"
|
||||
let init_images_dir = await pluginFolder.getEntry(
|
||||
'./server/python_server/init_images'
|
||||
)
|
||||
// let init_images_dir = await pluginFolder.getEntry(
|
||||
// './server/python_server/init_images'
|
||||
// )
|
||||
const file = await init_images_dir.createFile(image_name, {
|
||||
overwrite: true,
|
||||
})
|
||||
|
||||
const currentDocument = app.activeDocument
|
||||
await currentDocument.saveAs.png(
|
||||
file,
|
||||
{
|
||||
compression: 6,
|
||||
},
|
||||
true
|
||||
)
|
||||
|
||||
// const arrayBuffer = await file.read({format: formats.binary}) ;
|
||||
// console.log(arrayBuffer, 'arrayBuffer') ;
|
||||
},
|
||||
|
||||
{ commandName: 'readPng' }
|
||||
)
|
||||
// let init_images_dir = await pluginFolder.getEntry(
|
||||
// './server/python_server/init_images'
|
||||
// )
|
||||
const file = await init_images_dir.createFile(image_name, {
|
||||
overwrite: true,
|
||||
})
|
||||
|
||||
const currentDocument = app.activeDocument
|
||||
await currentDocument.saveAs.png(
|
||||
file,
|
||||
{
|
||||
compression: 6,
|
||||
},
|
||||
true
|
||||
)
|
||||
|
||||
// const arrayBuffer = await file.read({format: formats.binary}) ;
|
||||
// console.log(arrayBuffer, 'arrayBuffer') ;
|
||||
},
|
||||
|
||||
{ commandName: "readPng" }
|
||||
)
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
}
|
||||
|
||||
const psapi = require("./psapi")
|
||||
const psapi = require('./psapi')
|
||||
async function newExportPng(layer, image_name) {
|
||||
//store layers we want to export in variables
|
||||
// let layerToExports =
|
||||
// create new document
|
||||
// duplicate the layers to the new documnet
|
||||
//select the layer channel selectLayerChannelCommand
|
||||
//document.crop
|
||||
//export using readPng()
|
||||
//store layers we want to export in variables
|
||||
// let layerToExports =
|
||||
// create new document
|
||||
// duplicate the layers to the new documnet
|
||||
//select the layer channel selectLayerChannelCommand
|
||||
//document.crop
|
||||
//export using readPng()
|
||||
|
||||
try {
|
||||
//get the active layers
|
||||
// const layersToExport = app.activeDocument.activeLayers
|
||||
try {
|
||||
//get the active layers
|
||||
// const layersToExport = app.activeDocument.activeLayers
|
||||
|
||||
//create new document
|
||||
let exportDoc = await executeAsModal(async () => {
|
||||
return await app.documents.add
|
||||
})
|
||||
//create new document
|
||||
let exportDoc = await executeAsModal(async () => {
|
||||
return await app.documents.add
|
||||
})
|
||||
|
||||
// for (layer of layersToExport) {
|
||||
await executeAsModal(async () => {
|
||||
console.log(layer.id)
|
||||
const dupLayer = await layer.duplicate(exportDoc)
|
||||
await psapi.selectLayers([dupLayer])
|
||||
await psapi.selectLayerChannelCommand()
|
||||
const selection_info = await psapi.getSelectionInfoExe()
|
||||
await exportDoc.crop(selection_info)
|
||||
// export_image_name = `${layer.name}.png`
|
||||
await readPng(image_name)
|
||||
// await exportDoc.closeWithoutSaving()
|
||||
})
|
||||
// }
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
// for (layer of layersToExport) {
|
||||
await executeAsModal(async () => {
|
||||
console.log(layer.id)
|
||||
const dupLayer = await layer.duplicate(exportDoc)
|
||||
await psapi.selectLayers([dupLayer])
|
||||
await psapi.selectLayerChannelCommand()
|
||||
const selection_info = await psapi.getSelectionInfoExe()
|
||||
await exportDoc.crop(selection_info)
|
||||
// export_image_name = `${layer.name}.png`
|
||||
await readPng(image_name)
|
||||
// await exportDoc.closeWithoutSaving()
|
||||
})
|
||||
// }
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////Start method 3///////////////////////
|
||||
|
|
@ -140,68 +140,70 @@ For the save function, if running UXP AP1 version 1 then use "wait" for modalBeh
|
|||
If running on UXP API version 2 then use "execute" for modalBahavior, or remove the options and use {} so the options go to default.
|
||||
*/
|
||||
async function savePNG(saveDataTemp) {
|
||||
const batchPlay = require("photoshop").action.batchPlay
|
||||
const batchPlay = require('photoshop').action.batchPlay
|
||||
|
||||
async function savePNGCommand() {
|
||||
var saveFolder =
|
||||
await require("uxp").storage.localFileSystem.getPluginFolder()
|
||||
async function savePNGCommand() {
|
||||
var saveFolder =
|
||||
await require('uxp').storage.localFileSystem.getPluginFolder()
|
||||
|
||||
// Again, my variable here is global and assigned earlier. The value is changed during a batch loop for each file.
|
||||
var saveFile = await saveFolder.createFile("fileName.png")
|
||||
// Again, my variable here is global and assigned earlier. The value is changed during a batch loop for each file.
|
||||
var saveFile = await saveFolder.createFile('fileName.png')
|
||||
|
||||
const saveData =
|
||||
await require("uxp").storage.localFileSystem.createSessionToken(saveFile)
|
||||
const saveData =
|
||||
await require('uxp').storage.localFileSystem.createSessionToken(
|
||||
saveFile
|
||||
)
|
||||
|
||||
const result = await batchPlay(
|
||||
[
|
||||
{
|
||||
_obj: "save",
|
||||
as: {
|
||||
_obj: "PNGFormat",
|
||||
method: {
|
||||
_enum: "PNGMethod",
|
||||
_value: "quick",
|
||||
},
|
||||
PNGInterlaceType: {
|
||||
_enum: "PNGInterlaceType",
|
||||
_value: "PNGInterlaceNone",
|
||||
},
|
||||
PNGFilter: {
|
||||
_enum: "PNGFilter",
|
||||
_value: "PNGFilterAdaptive",
|
||||
},
|
||||
compression: 6,
|
||||
},
|
||||
in: {
|
||||
_path: saveData,
|
||||
_kind: "local",
|
||||
},
|
||||
saveStage: {
|
||||
_enum: "saveStageType",
|
||||
_value: "saveBegin",
|
||||
},
|
||||
_isCommand: false,
|
||||
_options: {
|
||||
dialogOptions: "dontDisplay",
|
||||
},
|
||||
},
|
||||
],
|
||||
{
|
||||
synchronousExecution: true,
|
||||
modalBehavior: "execute",
|
||||
}
|
||||
)
|
||||
}
|
||||
await executeAsModal(async () => {
|
||||
savePNGCommand()
|
||||
})
|
||||
const result = await batchPlay(
|
||||
[
|
||||
{
|
||||
_obj: 'save',
|
||||
as: {
|
||||
_obj: 'PNGFormat',
|
||||
method: {
|
||||
_enum: 'PNGMethod',
|
||||
_value: 'quick',
|
||||
},
|
||||
PNGInterlaceType: {
|
||||
_enum: 'PNGInterlaceType',
|
||||
_value: 'PNGInterlaceNone',
|
||||
},
|
||||
PNGFilter: {
|
||||
_enum: 'PNGFilter',
|
||||
_value: 'PNGFilterAdaptive',
|
||||
},
|
||||
compression: 6,
|
||||
},
|
||||
in: {
|
||||
_path: saveData,
|
||||
_kind: 'local',
|
||||
},
|
||||
saveStage: {
|
||||
_enum: 'saveStageType',
|
||||
_value: 'saveBegin',
|
||||
},
|
||||
_isCommand: false,
|
||||
_options: {
|
||||
dialogOptions: 'dontDisplay',
|
||||
},
|
||||
},
|
||||
],
|
||||
{
|
||||
synchronousExecution: true,
|
||||
modalBehavior: 'execute',
|
||||
}
|
||||
)
|
||||
}
|
||||
await executeAsModal(async () => {
|
||||
savePNGCommand()
|
||||
})
|
||||
}
|
||||
|
||||
////////////////////End method 3////////////////////////////
|
||||
|
||||
module.exports = {
|
||||
exportPng,
|
||||
readPng,
|
||||
savePNG,
|
||||
newExportPng,
|
||||
exportPng,
|
||||
readPng,
|
||||
savePNG,
|
||||
newExportPng,
|
||||
}
|
||||
|
|
|
|||
172
helper.js
172
helper.js
|
|
@ -1,110 +1,110 @@
|
|||
const { unselectActiveLayers } = require("./psapi")
|
||||
const { unselectActiveLayers } = require('./psapi')
|
||||
|
||||
const app = window.require("photoshop").app
|
||||
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 })
|
||||
}
|
||||
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]
|
||||
return activeLayers[0]
|
||||
}
|
||||
|
||||
function getSize() {
|
||||
let doc = app.activeDocument
|
||||
return { height: doc.height, width: doc.width }
|
||||
let doc = app.activeDocument
|
||||
return { height: doc.height, width: doc.width }
|
||||
}
|
||||
|
||||
const { batchPlay } = require("photoshop").action
|
||||
const { executeAsModal } = require("photoshop").core
|
||||
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",
|
||||
},
|
||||
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',
|
||||
},
|
||||
},
|
||||
],
|
||||
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",
|
||||
}
|
||||
)
|
||||
{
|
||||
synchronousExecution: true,
|
||||
modalBehavior: 'execute',
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async function reselect(selectionInfo) {
|
||||
await executeAsModal(
|
||||
async () => {
|
||||
reselectBatchPlay(selectionInfo)
|
||||
},
|
||||
{ commandName: "reselect" }
|
||||
)
|
||||
await executeAsModal(
|
||||
async () => {
|
||||
reselectBatchPlay(selectionInfo)
|
||||
},
|
||||
{ commandName: 'reselect' }
|
||||
)
|
||||
}
|
||||
|
||||
//unselect the rectangular marquee selection area
|
||||
async function unSelect() {
|
||||
const batchPlay = require("photoshop").action.batchPlay
|
||||
const batchPlay = require('photoshop').action.batchPlay
|
||||
|
||||
const result = await batchPlay(
|
||||
[
|
||||
{
|
||||
_obj: "set",
|
||||
_target: [
|
||||
{
|
||||
_ref: "channel",
|
||||
_property: "selection",
|
||||
},
|
||||
const result = await batchPlay(
|
||||
[
|
||||
{
|
||||
_obj: 'set',
|
||||
_target: [
|
||||
{
|
||||
_ref: 'channel',
|
||||
_property: 'selection',
|
||||
},
|
||||
],
|
||||
to: {
|
||||
_enum: 'ordinal',
|
||||
_value: 'none',
|
||||
},
|
||||
_options: {
|
||||
dialogOptions: 'dontDisplay',
|
||||
},
|
||||
},
|
||||
],
|
||||
to: {
|
||||
_enum: "ordinal",
|
||||
_value: "none",
|
||||
},
|
||||
_options: {
|
||||
dialogOptions: "dontDisplay",
|
||||
},
|
||||
},
|
||||
],
|
||||
{
|
||||
synchronousExecution: true,
|
||||
modalBehavior: "execute",
|
||||
}
|
||||
)
|
||||
{
|
||||
synchronousExecution: true,
|
||||
modalBehavior: 'execute',
|
||||
}
|
||||
)
|
||||
|
||||
return result
|
||||
return result
|
||||
}
|
||||
|
||||
// async function layerToSelectionHelper () {
|
||||
|
|
@ -203,5 +203,5 @@ async function unSelect() {
|
|||
// }
|
||||
|
||||
module.exports = {
|
||||
// layerToSelection
|
||||
// layerToSelection
|
||||
}
|
||||
|
|
|
|||
2498
index.html
2498
index.html
File diff suppressed because it is too large
Load Diff
1019
outpaint.js
1019
outpaint.js
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
19
package.json
19
package.json
|
|
@ -1,10 +1,13 @@
|
|||
{
|
||||
"name": "uxp-template-default-starter",
|
||||
"version": "1.0.0",
|
||||
"description": "Default template for creating Adobe UXP based photoshop plugin.",
|
||||
"author": "Adobe Inc",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"fastify": "^4.10.2"
|
||||
}
|
||||
"name": "uxp-template-default-starter",
|
||||
"version": "1.0.0",
|
||||
"description": "Default template for creating Adobe UXP based photoshop plugin.",
|
||||
"author": "Adobe Inc",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"fastify": "^4.10.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"prettier": "2.8.3"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
676
sdapi.js
676
sdapi.js
|
|
@ -1,234 +1,234 @@
|
|||
//javascript plugin can't read images from local directory so we send a request to local server to read the image file and send it back to plugin as image string base64
|
||||
async function getInitImage(init_image_name) {
|
||||
console.log("getInitImage(): get Init Image from the server :")
|
||||
const payload = {
|
||||
init_image_name: init_image_name,
|
||||
}
|
||||
console.log('getInitImage(): get Init Image from the server :')
|
||||
const payload = {
|
||||
init_image_name: init_image_name,
|
||||
}
|
||||
|
||||
const full_url = "http://127.0.0.1:8000/getInitImage/"
|
||||
console.log(full_url)
|
||||
console.log("getInitImage payload:", payload)
|
||||
let request = await fetch(full_url, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
// "body": payload
|
||||
})
|
||||
const full_url = 'http://127.0.0.1:8000/getInitImage/'
|
||||
console.log(full_url)
|
||||
console.log('getInitImage payload:', payload)
|
||||
let request = await fetch(full_url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
// "body": payload
|
||||
})
|
||||
|
||||
let json = await request.json()
|
||||
console.log("json:")
|
||||
console.dir(json)
|
||||
base64data = json.init_image_str
|
||||
image_src = `data:image/png;base64, ${base64data}`
|
||||
return image_src
|
||||
let json = await request.json()
|
||||
console.log('json:')
|
||||
console.dir(json)
|
||||
base64data = json.init_image_str
|
||||
image_src = `data:image/png;base64, ${base64data}`
|
||||
return image_src
|
||||
|
||||
// console.log(img.src)
|
||||
// console.log(img.src)
|
||||
|
||||
// let img_blob = await (await fetch(img.src)).blob()
|
||||
// console.log("img_blob:")
|
||||
// console.dir(img_blob)
|
||||
// let img_blob = await (await fetch(img.src)).blob()
|
||||
// console.log("img_blob:")
|
||||
// console.dir(img_blob)
|
||||
}
|
||||
|
||||
async function requestTxt2Img(payload) {
|
||||
try {
|
||||
console.log("requestTxt2Img(): about to send a fetch request")
|
||||
try {
|
||||
console.log('requestTxt2Img(): about to send a fetch request')
|
||||
|
||||
const full_url = "http://127.0.0.1:8000/txt2img/"
|
||||
console.log(full_url)
|
||||
const full_url = 'http://127.0.0.1:8000/txt2img/'
|
||||
console.log(full_url)
|
||||
|
||||
let request = await fetch(full_url, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
// "body": payload
|
||||
})
|
||||
let request = await fetch(full_url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
// "body": payload
|
||||
})
|
||||
|
||||
let json = await request.json()
|
||||
console.log("requestTxt2Img json:")
|
||||
console.dir(json)
|
||||
let json = await request.json()
|
||||
console.log('requestTxt2Img json:')
|
||||
console.dir(json)
|
||||
|
||||
return json
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
return {}
|
||||
}
|
||||
return json
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
async function requestImg2Img(payload) {
|
||||
console.log("requestImg2Img(): about to send a fetch request")
|
||||
try {
|
||||
const full_url = "http://127.0.0.1:8000/img2img/"
|
||||
console.log(full_url)
|
||||
console.log("requestImg2Img payload is: ", payload)
|
||||
let request = await fetch(full_url, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
// "body": payload
|
||||
})
|
||||
console.log('requestImg2Img(): about to send a fetch request')
|
||||
try {
|
||||
const full_url = 'http://127.0.0.1:8000/img2img/'
|
||||
console.log(full_url)
|
||||
console.log('requestImg2Img payload is: ', payload)
|
||||
let request = await fetch(full_url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
// "body": payload
|
||||
})
|
||||
|
||||
let json = await request.json()
|
||||
console.log("requestImg2Img json:")
|
||||
console.dir(json)
|
||||
let json = await request.json()
|
||||
console.log('requestImg2Img json:')
|
||||
console.dir(json)
|
||||
|
||||
return json
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
return {}
|
||||
}
|
||||
return json
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
async function requestProgress() {
|
||||
console.log("requestProgress: ")
|
||||
console.log('requestProgress: ')
|
||||
|
||||
const full_url =
|
||||
"http://127.0.0.1:8000/sdapi/v1/progress?skip_current_image=false"
|
||||
let request = await fetch(full_url)
|
||||
let json = await request.json()
|
||||
console.log("progress json:")
|
||||
console.dir(json)
|
||||
|
||||
return json
|
||||
}
|
||||
|
||||
async function requestGetModels() {
|
||||
console.log("requestGetModels: ")
|
||||
let json = []
|
||||
try {
|
||||
const full_url = "http://127.0.0.1:8000/sdapi/v1/sd-models"
|
||||
const full_url =
|
||||
'http://127.0.0.1:8000/sdapi/v1/progress?skip_current_image=false'
|
||||
let request = await fetch(full_url)
|
||||
json = await request.json()
|
||||
console.log("models json:")
|
||||
console.dir(json)
|
||||
} catch (e) {
|
||||
console.warn(`issues requesting from ${full_url}`, e)
|
||||
}
|
||||
return json
|
||||
}
|
||||
|
||||
async function requestGetSamplers() {
|
||||
console.log("requestGetSamplers: ")
|
||||
|
||||
const full_url = "http://127.0.0.1:8000/sdapi/v1/samplers"
|
||||
let request = await fetch(full_url)
|
||||
let json = await request.json()
|
||||
console.log("samplers json:")
|
||||
console.dir(json)
|
||||
|
||||
return json
|
||||
}
|
||||
|
||||
async function requestSwapModel(model_title) {
|
||||
console.log("requestSwapModel: ")
|
||||
// const full_url = 'http://127.0.0.1:8000/swapModel'
|
||||
|
||||
const full_url = "http://127.0.0.1:8000/sdapi/v1/options"
|
||||
payload = {
|
||||
sd_model_checkpoint: model_title,
|
||||
}
|
||||
let request = await fetch(full_url, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
// "body": payload
|
||||
})
|
||||
|
||||
let json = await request.json()
|
||||
|
||||
console.log("models json:")
|
||||
console.dir(json)
|
||||
|
||||
return json
|
||||
}
|
||||
|
||||
async function requestInterrupt(model_title) {
|
||||
try {
|
||||
console.log("requestInterrupt: ")
|
||||
// const full_url = 'http://127.0.0.1:8000/swapModel'
|
||||
|
||||
const full_url = "http://127.0.0.1:8000/sdapi/v1/interrupt"
|
||||
// payload = {
|
||||
// sd_model_checkpoint: model_title
|
||||
// }
|
||||
payload = ""
|
||||
let request = await fetch(full_url, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
// body: JSON.stringify(payload)
|
||||
// "body": payload
|
||||
})
|
||||
|
||||
console.log("interrupt request:", request)
|
||||
let json = await request.json()
|
||||
|
||||
console.log("interrupt json:")
|
||||
console.log('progress json:')
|
||||
console.dir(json)
|
||||
|
||||
return json
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
}
|
||||
|
||||
async function requestGetModels() {
|
||||
console.log('requestGetModels: ')
|
||||
let json = []
|
||||
try {
|
||||
const full_url = 'http://127.0.0.1:8000/sdapi/v1/sd-models'
|
||||
let request = await fetch(full_url)
|
||||
json = await request.json()
|
||||
console.log('models json:')
|
||||
console.dir(json)
|
||||
} catch (e) {
|
||||
console.warn(`issues requesting from ${full_url}`, e)
|
||||
}
|
||||
return json
|
||||
}
|
||||
|
||||
async function requestGetSamplers() {
|
||||
console.log('requestGetSamplers: ')
|
||||
|
||||
const full_url = 'http://127.0.0.1:8000/sdapi/v1/samplers'
|
||||
let request = await fetch(full_url)
|
||||
let json = await request.json()
|
||||
console.log('samplers json:')
|
||||
console.dir(json)
|
||||
|
||||
return json
|
||||
}
|
||||
|
||||
async function requestSwapModel(model_title) {
|
||||
console.log('requestSwapModel: ')
|
||||
// const full_url = 'http://127.0.0.1:8000/swapModel'
|
||||
|
||||
const full_url = 'http://127.0.0.1:8000/sdapi/v1/options'
|
||||
payload = {
|
||||
sd_model_checkpoint: model_title,
|
||||
}
|
||||
let request = await fetch(full_url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
// "body": payload
|
||||
})
|
||||
|
||||
let json = await request.json()
|
||||
|
||||
console.log('models json:')
|
||||
console.dir(json)
|
||||
|
||||
return json
|
||||
}
|
||||
|
||||
async function requestInterrupt(model_title) {
|
||||
try {
|
||||
console.log('requestInterrupt: ')
|
||||
// const full_url = 'http://127.0.0.1:8000/swapModel'
|
||||
|
||||
const full_url = 'http://127.0.0.1:8000/sdapi/v1/interrupt'
|
||||
// payload = {
|
||||
// sd_model_checkpoint: model_title
|
||||
// }
|
||||
payload = ''
|
||||
let request = await fetch(full_url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
// body: JSON.stringify(payload)
|
||||
// "body": payload
|
||||
})
|
||||
|
||||
console.log('interrupt request:', request)
|
||||
let json = await request.json()
|
||||
|
||||
console.log('interrupt json:')
|
||||
console.dir(json)
|
||||
|
||||
return json
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
}
|
||||
|
||||
async function getVersionRequest() {
|
||||
// version = "v0.0.0"
|
||||
console.log("requestGetSamplers: ")
|
||||
try {
|
||||
const full_url = "http://127.0.0.1:8000/version"
|
||||
let request = await fetch(full_url)
|
||||
let json = await request.json()
|
||||
console.log("version json:", json)
|
||||
version = json["version"]
|
||||
// version = "v0.0.0"
|
||||
console.log('requestGetSamplers: ')
|
||||
try {
|
||||
const full_url = 'http://127.0.0.1:8000/version'
|
||||
let request = await fetch(full_url)
|
||||
let json = await request.json()
|
||||
console.log('version json:', json)
|
||||
version = json['version']
|
||||
|
||||
return version
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
version = "v0.0.0"
|
||||
return version
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
version = 'v0.0.0'
|
||||
|
||||
return version
|
||||
}
|
||||
return version
|
||||
}
|
||||
}
|
||||
|
||||
async function changeSdUrl(new_sd_url) {
|
||||
// version = "v0.0.0"
|
||||
console.log("changeSdUrl: new_sd_url:", new_sd_url)
|
||||
try {
|
||||
payload = {
|
||||
sd_url: new_sd_url,
|
||||
// version = "v0.0.0"
|
||||
console.log('changeSdUrl: new_sd_url:', new_sd_url)
|
||||
try {
|
||||
payload = {
|
||||
sd_url: new_sd_url,
|
||||
}
|
||||
|
||||
const full_url = 'http://127.0.0.1:8000/sd_url/'
|
||||
console.log('changeSdUrl: payload: ', payload)
|
||||
let request = await fetch(full_url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
|
||||
// let json = await request.json()
|
||||
// console.log('changeSdUrl:',json)
|
||||
console.log('changeSdUrl: request: ', request)
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
|
||||
const full_url = "http://127.0.0.1:8000/sd_url/"
|
||||
console.log("changeSdUrl: payload: ", payload)
|
||||
let request = await fetch(full_url, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
|
||||
// let json = await request.json()
|
||||
// console.log('changeSdUrl:',json)
|
||||
console.log("changeSdUrl: request: ", request)
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
}
|
||||
|
||||
// function printTheJSONInPrettyFormat(json) {
|
||||
|
|
@ -238,177 +238,177 @@ async function changeSdUrl(new_sd_url) {
|
|||
// // return
|
||||
// }
|
||||
async function loadHistory(uniqueDocumentId) {
|
||||
let json = {}
|
||||
try {
|
||||
payload = {
|
||||
uniqueDocumentId: uniqueDocumentId,
|
||||
let json = {}
|
||||
try {
|
||||
payload = {
|
||||
uniqueDocumentId: uniqueDocumentId,
|
||||
}
|
||||
|
||||
const full_url = 'http://127.0.0.1:8000/history/load'
|
||||
|
||||
let request = await fetch(full_url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
|
||||
json = await request.json()
|
||||
console.log('loadHistory:', json)
|
||||
// console.log('loadPromptShortcut: request: ',request)
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
|
||||
const full_url = "http://127.0.0.1:8000/history/load"
|
||||
|
||||
let request = await fetch(full_url, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
|
||||
json = await request.json()
|
||||
console.log("loadHistory:", json)
|
||||
// console.log('loadPromptShortcut: request: ',request)
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
|
||||
return [json["image_paths"], json["metadata_jsons"]]
|
||||
return [json['image_paths'], json['metadata_jsons']]
|
||||
}
|
||||
async function loadPromptShortcut() {
|
||||
// console.log('loadPromptShortcut:')
|
||||
let json = {}
|
||||
try {
|
||||
payload = {}
|
||||
// console.log('loadPromptShortcut:')
|
||||
let json = {}
|
||||
try {
|
||||
payload = {}
|
||||
|
||||
const full_url = "http://127.0.0.1:8000/prompt_shortcut/load"
|
||||
const full_url = 'http://127.0.0.1:8000/prompt_shortcut/load'
|
||||
|
||||
let request = await fetch(full_url, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
let request = await fetch(full_url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
|
||||
json = await request.json()
|
||||
console.log("loadPromptShortcut:", json)
|
||||
// console.log('loadPromptShortcut: request: ',request)
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
json = await request.json()
|
||||
console.log('loadPromptShortcut:', json)
|
||||
// console.log('loadPromptShortcut: request: ',request)
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
|
||||
return json["prompt_shortcut"]
|
||||
return json['prompt_shortcut']
|
||||
}
|
||||
|
||||
async function savePromptShortcut(prompt_shortcut) {
|
||||
// console.log('loadPromptShortcut:')
|
||||
let json = {}
|
||||
try {
|
||||
payload = { prompt_shortcut: prompt_shortcut }
|
||||
// console.log('loadPromptShortcut:')
|
||||
let json = {}
|
||||
try {
|
||||
payload = { prompt_shortcut: prompt_shortcut }
|
||||
|
||||
const full_url = "http://127.0.0.1:8000/prompt_shortcut/save"
|
||||
const full_url = 'http://127.0.0.1:8000/prompt_shortcut/save'
|
||||
|
||||
let request = await fetch(full_url, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
let request = await fetch(full_url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
|
||||
json = await request.json()
|
||||
console.log("savePromptShortcut:", json)
|
||||
// console.log('loadPromptShortcut: request: ',request)
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
json = await request.json()
|
||||
console.log('savePromptShortcut:', json)
|
||||
// console.log('loadPromptShortcut: request: ',request)
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
|
||||
return json["prompt_shortcut"]
|
||||
return json['prompt_shortcut']
|
||||
}
|
||||
async function setInpaintMaskWeight(value) {
|
||||
const full_url = "http://127.0.0.1:8000/sdapi/v1/options"
|
||||
try {
|
||||
payload = {
|
||||
inpainting_mask_weight: value,
|
||||
const full_url = 'http://127.0.0.1:8000/sdapi/v1/options'
|
||||
try {
|
||||
payload = {
|
||||
inpainting_mask_weight: value,
|
||||
}
|
||||
await fetch(full_url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
await fetch(full_url, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
}
|
||||
|
||||
async function requestGetConfig() {
|
||||
console.log("requestGetConfig: ")
|
||||
let json = []
|
||||
const full_url = "http://127.0.0.1:8000/config"
|
||||
try {
|
||||
let request = await fetch(full_url)
|
||||
json = await request.json()
|
||||
console.log("models json:")
|
||||
console.dir(json)
|
||||
} catch (e) {
|
||||
console.warn(`issues requesting from ${full_url}`, e)
|
||||
}
|
||||
return json
|
||||
console.log('requestGetConfig: ')
|
||||
let json = []
|
||||
const full_url = 'http://127.0.0.1:8000/config'
|
||||
try {
|
||||
let request = await fetch(full_url)
|
||||
json = await request.json()
|
||||
console.log('models json:')
|
||||
console.dir(json)
|
||||
} catch (e) {
|
||||
console.warn(`issues requesting from ${full_url}`, e)
|
||||
}
|
||||
return json
|
||||
}
|
||||
async function requestGetOptions() {
|
||||
console.log("requestGetOptions: ")
|
||||
let json = []
|
||||
const full_url = "http://127.0.0.1:8000/sdapi/v1/options"
|
||||
try {
|
||||
let request = await fetch(full_url)
|
||||
json = await request.json()
|
||||
console.log("models json:")
|
||||
console.dir(json)
|
||||
} catch (e) {
|
||||
console.warn(`issues requesting from ${full_url}`, e)
|
||||
}
|
||||
return json
|
||||
console.log('requestGetOptions: ')
|
||||
let json = []
|
||||
const full_url = 'http://127.0.0.1:8000/sdapi/v1/options'
|
||||
try {
|
||||
let request = await fetch(full_url)
|
||||
json = await request.json()
|
||||
console.log('models json:')
|
||||
console.dir(json)
|
||||
} catch (e) {
|
||||
console.warn(`issues requesting from ${full_url}`, e)
|
||||
}
|
||||
return json
|
||||
}
|
||||
|
||||
async function imageSearch(keywords) {
|
||||
let json = {}
|
||||
try {
|
||||
payload = {
|
||||
keywords: keywords,
|
||||
let json = {}
|
||||
try {
|
||||
payload = {
|
||||
keywords: keywords,
|
||||
}
|
||||
|
||||
const full_url = 'http://127.0.0.1:8000/search/image/'
|
||||
|
||||
let request = await fetch(full_url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
|
||||
json = await request.json()
|
||||
console.log('imageSearch:', json)
|
||||
|
||||
return json['images']
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
|
||||
const full_url = "http://127.0.0.1:8000/search/image/"
|
||||
|
||||
let request = await fetch(full_url, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
|
||||
json = await request.json()
|
||||
console.log("imageSearch:", json)
|
||||
|
||||
return json["images"]
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
return []
|
||||
return []
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
requestTxt2Img,
|
||||
requestImg2Img,
|
||||
getInitImage,
|
||||
requestProgress,
|
||||
requestGetModels,
|
||||
requestSwapModel,
|
||||
requestInterrupt,
|
||||
requestGetSamplers,
|
||||
getVersionRequest,
|
||||
changeSdUrl,
|
||||
loadPromptShortcut,
|
||||
savePromptShortcut,
|
||||
loadHistory,
|
||||
setInpaintMaskWeight,
|
||||
requestGetConfig,
|
||||
requestGetOptions,
|
||||
imageSearch,
|
||||
requestTxt2Img,
|
||||
requestImg2Img,
|
||||
getInitImage,
|
||||
requestProgress,
|
||||
requestGetModels,
|
||||
requestSwapModel,
|
||||
requestInterrupt,
|
||||
requestGetSamplers,
|
||||
getVersionRequest,
|
||||
changeSdUrl,
|
||||
loadPromptShortcut,
|
||||
savePromptShortcut,
|
||||
loadHistory,
|
||||
setInpaintMaskWeight,
|
||||
requestGetConfig,
|
||||
requestGetOptions,
|
||||
imageSearch,
|
||||
}
|
||||
|
|
|
|||
82
selection.js
82
selection.js
|
|
@ -1,56 +1,56 @@
|
|||
function finalWidthHeight(
|
||||
selectionWidth,
|
||||
selectionHeight,
|
||||
minWidth,
|
||||
minHeight
|
||||
selectionWidth,
|
||||
selectionHeight,
|
||||
minWidth,
|
||||
minHeight
|
||||
) {
|
||||
// const minWidth = 512
|
||||
// const minHeight = 512
|
||||
// const minWidth = 512
|
||||
// const minHeight = 512
|
||||
|
||||
// const selectionWidth = 256
|
||||
// const selectionHeight = 1000
|
||||
// const selectionWidth = 256
|
||||
// const selectionHeight = 1000
|
||||
|
||||
let finalWidth = 0
|
||||
let finalHeight = 0
|
||||
let finalWidth = 0
|
||||
let finalHeight = 0
|
||||
|
||||
if (selectionWidth <= selectionHeight) {
|
||||
//do operation on the smaller dimension
|
||||
const scaleRatio = selectionWidth / minWidth
|
||||
if (selectionWidth <= selectionHeight) {
|
||||
//do operation on the smaller dimension
|
||||
const scaleRatio = selectionWidth / minWidth
|
||||
|
||||
finalWidth = minWidth
|
||||
finalHeight = selectionHeight / scaleRatio
|
||||
} else {
|
||||
const scaleRatio = selectionHeight / minHeight
|
||||
finalWidth = minWidth
|
||||
finalHeight = selectionHeight / scaleRatio
|
||||
} else {
|
||||
const scaleRatio = selectionHeight / minHeight
|
||||
|
||||
finalHeight = minHeight
|
||||
finalWidth = selectionWidth / scaleRatio
|
||||
}
|
||||
return [finalWidth, finalHeight]
|
||||
finalHeight = minHeight
|
||||
finalWidth = selectionWidth / scaleRatio
|
||||
}
|
||||
return [finalWidth, finalHeight]
|
||||
}
|
||||
|
||||
async function selectionToFinalWidthHeight() {
|
||||
const { getSelectionInfoExe } = require("./psapi")
|
||||
try {
|
||||
const selectionInfo = await getSelectionInfoExe()
|
||||
const [finalWidth, finalHeight] = finalWidthHeight(
|
||||
selectionInfo.width,
|
||||
selectionInfo.height,
|
||||
512,
|
||||
512
|
||||
)
|
||||
const { getSelectionInfoExe } = require('./psapi')
|
||||
try {
|
||||
const selectionInfo = await getSelectionInfoExe()
|
||||
const [finalWidth, finalHeight] = finalWidthHeight(
|
||||
selectionInfo.width,
|
||||
selectionInfo.height,
|
||||
512,
|
||||
512
|
||||
)
|
||||
|
||||
return [
|
||||
parseInt(finalWidth),
|
||||
parseInt(finalHeight),
|
||||
selectionInfo.width,
|
||||
selectionInfo.height,
|
||||
]
|
||||
} catch (e) {
|
||||
console.warn("you need a rectangular selection", e)
|
||||
}
|
||||
return [
|
||||
parseInt(finalWidth),
|
||||
parseInt(finalHeight),
|
||||
selectionInfo.width,
|
||||
selectionInfo.height,
|
||||
]
|
||||
} catch (e) {
|
||||
console.warn('you need a rectangular selection', e)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
finalWidthHeight,
|
||||
selectionToFinalWidthHeight,
|
||||
finalWidthHeight,
|
||||
selectionToFinalWidthHeight,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
////// Start Prompt//////////
|
||||
|
||||
function getPrompt() {
|
||||
const prompt = document.getElementById("taPrompt").value
|
||||
return prompt
|
||||
const prompt = document.getElementById('taPrompt').value
|
||||
return prompt
|
||||
}
|
||||
|
||||
function autoFillInPrompt(prompt_value) {
|
||||
document.getElementById("taPrompt").value = prompt_value
|
||||
document.getElementById('taPrompt').value = prompt_value
|
||||
}
|
||||
|
||||
////// End Prompt//////////
|
||||
|
|
@ -14,316 +14,319 @@ function autoFillInPrompt(prompt_value) {
|
|||
////// Start Negative Prompt//////////
|
||||
|
||||
function getNegativePrompt() {
|
||||
const negative_prompt = document.getElementById("taNegativePrompt").value
|
||||
return negative_prompt
|
||||
const negative_prompt = document.getElementById('taNegativePrompt').value
|
||||
return negative_prompt
|
||||
}
|
||||
|
||||
function autoFillInNegativePrompt(negative_prompt_value) {
|
||||
document.getElementById("taNegativePrompt").value = negative_prompt_value
|
||||
document.getElementById('taNegativePrompt').value = negative_prompt_value
|
||||
}
|
||||
|
||||
////// End Negative Prompt//////////
|
||||
|
||||
////// Start Width//////////
|
||||
|
||||
document.getElementById("slWidth").addEventListener("input", (evt) => {
|
||||
const width = evt.target.value * 64
|
||||
document.getElementById("lWidth").textContent = width
|
||||
document.getElementById('slWidth').addEventListener('input', (evt) => {
|
||||
const width = evt.target.value * 64
|
||||
document.getElementById('lWidth').textContent = width
|
||||
})
|
||||
|
||||
function getWidth() {
|
||||
slider_width = document.getElementById("slWidth").value
|
||||
const width = slider_width * 64
|
||||
return width
|
||||
slider_width = document.getElementById('slWidth').value
|
||||
const width = slider_width * 64
|
||||
return width
|
||||
}
|
||||
|
||||
function getHrWidth() {
|
||||
slider_width = document.getElementById("hrWidth").value
|
||||
const width = slider_width * 64
|
||||
return width
|
||||
slider_width = document.getElementById('hrWidth').value
|
||||
const width = slider_width * 64
|
||||
return width
|
||||
}
|
||||
|
||||
function getHrHeight() {
|
||||
slider_width = document.getElementById("hrHeight").value
|
||||
const width = slider_width * 64
|
||||
return width
|
||||
slider_width = document.getElementById('hrHeight').value
|
||||
const width = slider_width * 64
|
||||
return width
|
||||
}
|
||||
function autoFillInWidth(width_value) {
|
||||
document.getElementById("slWidth").value = `${width_value / 64}`
|
||||
//update the label
|
||||
document.getElementById("lWidth").innerHTML = `${width_value}`
|
||||
document.getElementById('slWidth').value = `${width_value / 64}`
|
||||
//update the label
|
||||
document.getElementById('lWidth').innerHTML = `${width_value}`
|
||||
}
|
||||
////// End Width//////////
|
||||
|
||||
////// Start Height//////////
|
||||
|
||||
document.getElementById("slHeight").addEventListener("input", (evt) => {
|
||||
const height = evt.target.value * 64
|
||||
document.getElementById("lHeight").textContent = height
|
||||
document.getElementById('slHeight').addEventListener('input', (evt) => {
|
||||
const height = evt.target.value * 64
|
||||
document.getElementById('lHeight').textContent = height
|
||||
})
|
||||
|
||||
function getHeight() {
|
||||
slider_value = document.getElementById("slHeight").value
|
||||
const height = slider_value * 64
|
||||
return height
|
||||
slider_value = document.getElementById('slHeight').value
|
||||
const height = slider_value * 64
|
||||
return height
|
||||
}
|
||||
|
||||
function autoFillInHeight(height_value) {
|
||||
document.getElementById("slHeight").value = `${height_value / 64}`
|
||||
//update the label
|
||||
document.getElementById("lHeight").innerHTML = `${height_value}`
|
||||
document.getElementById('slHeight').value = `${height_value / 64}`
|
||||
//update the label
|
||||
document.getElementById('lHeight').innerHTML = `${height_value}`
|
||||
}
|
||||
|
||||
function autoFillInHRHeight(height_value) {
|
||||
document.getElementById("hrHeight").value = `${height_value / 64}`
|
||||
//update the label
|
||||
document.getElementById("hHeight").innerHTML = `${height_value}`
|
||||
document.getElementById('hrHeight').value = `${height_value / 64}`
|
||||
//update the label
|
||||
document.getElementById('hHeight').innerHTML = `${height_value}`
|
||||
}
|
||||
|
||||
function autoFillInHRWidth(height_value) {
|
||||
document.getElementById("hrWidth").value = `${height_value / 64}`
|
||||
//update the label
|
||||
document.getElementById("hWidth").innerHTML = `${height_value}`
|
||||
document.getElementById('hrWidth').value = `${height_value / 64}`
|
||||
//update the label
|
||||
document.getElementById('hWidth').innerHTML = `${height_value}`
|
||||
}
|
||||
|
||||
////// End Height//////////
|
||||
|
||||
////// Start Denoising Strength//////////
|
||||
document
|
||||
.querySelector("#slDenoisingStrength")
|
||||
.addEventListener("input", (evt) => {
|
||||
const label_value = evt.target.value / 100
|
||||
// console.log("label_value: ", label_value)
|
||||
document.getElementById("lDenoisingStrength").innerHTML = `${label_value}`
|
||||
})
|
||||
.querySelector('#slDenoisingStrength')
|
||||
.addEventListener('input', (evt) => {
|
||||
const label_value = evt.target.value / 100
|
||||
// console.log("label_value: ", label_value)
|
||||
document.getElementById(
|
||||
'lDenoisingStrength'
|
||||
).innerHTML = `${label_value}`
|
||||
})
|
||||
|
||||
//get the value that is relevant to stable diffusion
|
||||
function getDenoisingStrength() {
|
||||
const slider_value = document.getElementById("slDenoisingStrength").value
|
||||
const denoising_strength_value = slider_value / 100.0
|
||||
return denoising_strength_value
|
||||
const slider_value = document.getElementById('slDenoisingStrength').value
|
||||
const denoising_strength_value = slider_value / 100.0
|
||||
return denoising_strength_value
|
||||
}
|
||||
|
||||
// display the value the user need to see in all elements related to denoising strength attribute
|
||||
function autoFillInDenoisingStrength(denoising_strength_value) {
|
||||
//sd denoising strength value range from [0,1] slider range from [0, 100]
|
||||
//update the slider
|
||||
document.getElementById("slDenoisingStrength").value = `${
|
||||
denoising_strength_value * 100
|
||||
}`
|
||||
//update the label
|
||||
document.getElementById(
|
||||
"lDenoisingStrength"
|
||||
).innerHTML = `${denoising_strength_value}`
|
||||
//sd denoising strength value range from [0,1] slider range from [0, 100]
|
||||
//update the slider
|
||||
document.getElementById('slDenoisingStrength').value = `${
|
||||
denoising_strength_value * 100
|
||||
}`
|
||||
//update the label
|
||||
document.getElementById(
|
||||
'lDenoisingStrength'
|
||||
).innerHTML = `${denoising_strength_value}`
|
||||
}
|
||||
|
||||
////// End Denoising Strength//////////
|
||||
|
||||
////// Start Hi Res Fix//////////
|
||||
|
||||
document.getElementById("chInpaintFullRes").addEventListener("click", (ev) => {
|
||||
const inpaint_padding_slider = document.getElementById("slInpaintPadding")
|
||||
document.getElementById('chInpaintFullRes').addEventListener('click', (ev) => {
|
||||
const inpaint_padding_slider = document.getElementById('slInpaintPadding')
|
||||
|
||||
if (ev.target.checked) {
|
||||
inpaint_padding_slider.style.display = "block"
|
||||
} else {
|
||||
inpaint_padding_slider.style.display = "none"
|
||||
}
|
||||
if (ev.target.checked) {
|
||||
inpaint_padding_slider.style.display = 'block'
|
||||
} else {
|
||||
inpaint_padding_slider.style.display = 'none'
|
||||
}
|
||||
})
|
||||
document.getElementById("chHiResFixs").addEventListener("click", (ev) => {
|
||||
const container = document.getElementById("hi-res-sliders-container")
|
||||
document.getElementById('chHiResFixs').addEventListener('click', (ev) => {
|
||||
const container = document.getElementById('hi-res-sliders-container')
|
||||
|
||||
if (ev.target.checked) {
|
||||
container.style.display = "flex"
|
||||
} else {
|
||||
container.style.display = "none"
|
||||
}
|
||||
if (ev.target.checked) {
|
||||
container.style.display = 'flex'
|
||||
} else {
|
||||
container.style.display = 'none'
|
||||
}
|
||||
})
|
||||
//get the value that is relevant to stable diffusion
|
||||
function getHiResFixs() {
|
||||
const isChecked = document.getElementById("chHiResFixs").checked
|
||||
return isChecked
|
||||
const isChecked = document.getElementById('chHiResFixs').checked
|
||||
return isChecked
|
||||
}
|
||||
|
||||
function setHiResFixs(isChecked) {
|
||||
document.getElementById("chHiResFixs").checked = isChecked
|
||||
document.getElementById('chHiResFixs').checked = isChecked
|
||||
}
|
||||
|
||||
function sliderAddEventListener(slider_id, label_id, multiplier) {
|
||||
document.getElementById(slider_id).addEventListener("input", (evt) => {
|
||||
const sd_value = evt.target.value * multiplier // convert slider value to SD ready value
|
||||
document.getElementById(label_id).textContent = Number(sd_value).toFixed(2)
|
||||
})
|
||||
document.getElementById(slider_id).addEventListener('input', (evt) => {
|
||||
const sd_value = evt.target.value * multiplier // convert slider value to SD ready value
|
||||
document.getElementById(label_id).textContent =
|
||||
Number(sd_value).toFixed(2)
|
||||
})
|
||||
}
|
||||
|
||||
//get the stable diffusion ready value from the slider with "slider_id"
|
||||
function getSliderSdValue(slider_id, multiplier) {
|
||||
const slider_value = document.getElementById(slider_id).value
|
||||
const sd_value = slider_value * multiplier
|
||||
return sd_value
|
||||
const slider_value = document.getElementById(slider_id).value
|
||||
const sd_value = slider_value * multiplier
|
||||
return sd_value
|
||||
}
|
||||
function autoFillInSliderUi(sd_value, slider_id, label_id, multiplier) {
|
||||
//update the slider
|
||||
document.getElementById(slider_id).value = `${sd_value * multiplier}`
|
||||
//update the label
|
||||
document.getElementById(label_id).innerHTML = `${sd_value}`
|
||||
//update the slider
|
||||
document.getElementById(slider_id).value = `${sd_value * multiplier}`
|
||||
//update the label
|
||||
document.getElementById(label_id).innerHTML = `${sd_value}`
|
||||
}
|
||||
|
||||
//hrWidth is from [1 to 32] * 64 => [64 to 2048]
|
||||
sliderAddEventListener("hrWidth", "hWidth", 64)
|
||||
sliderAddEventListener("hrHeight", "hHeight", 64)
|
||||
sliderAddEventListener('hrWidth', 'hWidth', 64)
|
||||
sliderAddEventListener('hrHeight', 'hHeight', 64)
|
||||
|
||||
//convert hrDenoisingStrength from [1, 100] * 0.01 => [0.01 to 1]
|
||||
sliderAddEventListener("hrDenoisingStrength", "hDenoisingStrength", 0.01)
|
||||
sliderAddEventListener('hrDenoisingStrength', 'hDenoisingStrength', 0.01)
|
||||
|
||||
function autoFillInHiResFixs(firstphase_width, firstphase_height) {
|
||||
//update the firstphase width slider and label
|
||||
autoFillInSliderUi(firstphase_width, "hrWidth", "hWidth", 1.0 / 64)
|
||||
//update the firstphase height slider and label
|
||||
autoFillInSliderUi(firstphase_height, "hrHeight", "hHeight", 1.0 / 64)
|
||||
//update the firstphase width slider and label
|
||||
autoFillInSliderUi(firstphase_width, 'hrWidth', 'hWidth', 1.0 / 64)
|
||||
//update the firstphase height slider and label
|
||||
autoFillInSliderUi(firstphase_height, 'hrHeight', 'hHeight', 1.0 / 64)
|
||||
}
|
||||
////// End Hi Res Fix//////////
|
||||
|
||||
////// Start Inpaint Mask Weight//////////
|
||||
function autoFillInInpaintMaskWeight(sd_value) {
|
||||
//update the inpaint mask weight
|
||||
autoFillInSliderUi(
|
||||
sd_value,
|
||||
"slInpaintingMaskWeight",
|
||||
"lInpaintingMaskWeight",
|
||||
100
|
||||
)
|
||||
//update the inpaint mask weight
|
||||
autoFillInSliderUi(
|
||||
sd_value,
|
||||
'slInpaintingMaskWeight',
|
||||
'lInpaintingMaskWeight',
|
||||
100
|
||||
)
|
||||
}
|
||||
////// End Inpaint Mask Weight//////////
|
||||
|
||||
////// Start Samplers//////////
|
||||
function unCheckAllSamplers() {
|
||||
document
|
||||
.getElementsByClassName("rbSampler")
|
||||
.forEach((e) => e.removeAttribute("checked"))
|
||||
document
|
||||
.getElementsByClassName('rbSampler')
|
||||
.forEach((e) => e.removeAttribute('checked'))
|
||||
}
|
||||
|
||||
function getSamplerElementByName(sampler_name) {
|
||||
try {
|
||||
//assume the sampler_name is valid
|
||||
//return the first
|
||||
//convert htmlCollection into an array, then user filter to get the radio button with the value equals to sampler_name
|
||||
const sampler_element = [
|
||||
...document.getElementsByClassName("rbSampler"),
|
||||
].filter((e) => e.value == sampler_name)[0]
|
||||
return sampler_element
|
||||
} catch (e) {
|
||||
console.warn(`Sampler '${sampler_name}' not found ${e}`)
|
||||
}
|
||||
try {
|
||||
//assume the sampler_name is valid
|
||||
//return the first
|
||||
//convert htmlCollection into an array, then user filter to get the radio button with the value equals to sampler_name
|
||||
const sampler_element = [
|
||||
...document.getElementsByClassName('rbSampler'),
|
||||
].filter((e) => e.value == sampler_name)[0]
|
||||
return sampler_element
|
||||
} catch (e) {
|
||||
console.warn(`Sampler '${sampler_name}' not found ${e}`)
|
||||
}
|
||||
}
|
||||
|
||||
function getCheckedSamplerName() {
|
||||
//we assume that the samplers exist and loaded in html
|
||||
//return the name of the first checked sampler
|
||||
return [...document.getElementsByClassName("rbSampler")].filter(
|
||||
(e) => e.checked == true
|
||||
)[0].value
|
||||
//we assume that the samplers exist and loaded in html
|
||||
//return the name of the first checked sampler
|
||||
return [...document.getElementsByClassName('rbSampler')].filter(
|
||||
(e) => e.checked == true
|
||||
)[0].value
|
||||
}
|
||||
function getMode() {
|
||||
return [...document.getElementsByClassName("rbMode")].filter(
|
||||
(e) => e.checked == true
|
||||
)[0].value
|
||||
return [...document.getElementsByClassName('rbMode')].filter(
|
||||
(e) => e.checked == true
|
||||
)[0].value
|
||||
}
|
||||
|
||||
function checkSampler(sampler_name) {
|
||||
sampler_element = getSamplerElementByName(sampler_name)
|
||||
sampler_element.checked = true
|
||||
sampler_element = getSamplerElementByName(sampler_name)
|
||||
sampler_element.checked = true
|
||||
}
|
||||
function autoFillInSampler(sampler_name) {
|
||||
// unCheckAllSamplers()
|
||||
checkSampler(sampler_name)
|
||||
// unCheckAllSamplers()
|
||||
checkSampler(sampler_name)
|
||||
}
|
||||
////// End Samplers//////////
|
||||
|
||||
////// Start Models//////////
|
||||
|
||||
function getModelElementByHash(model_hash) {
|
||||
try {
|
||||
//assume the model_hash is valid
|
||||
//return the first model menu item element with model_hash
|
||||
const model_element = [
|
||||
...document.getElementsByClassName("mModelMenuItem"),
|
||||
].filter((e) => e.dataset.model_hash == model_hash)[0]
|
||||
return model_element
|
||||
} catch (e) {
|
||||
console.warn(`Model '${model_hash}' not found ${e}`)
|
||||
}
|
||||
try {
|
||||
//assume the model_hash is valid
|
||||
//return the first model menu item element with model_hash
|
||||
const model_element = [
|
||||
...document.getElementsByClassName('mModelMenuItem'),
|
||||
].filter((e) => e.dataset.model_hash == model_hash)[0]
|
||||
return model_element
|
||||
} catch (e) {
|
||||
console.warn(`Model '${model_hash}' not found ${e}`)
|
||||
}
|
||||
}
|
||||
function getModelHashByTitle(model_title) {
|
||||
//return find the model hash by it's title
|
||||
try {
|
||||
return [...document.getElementsByClassName("mModelMenuItem")].filter(
|
||||
(e) => e.dataset.model_title == model_title
|
||||
)[0].dataset.model_hash
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
//return find the model hash by it's title
|
||||
try {
|
||||
return [...document.getElementsByClassName('mModelMenuItem')].filter(
|
||||
(e) => e.dataset.model_title == model_title
|
||||
)[0].dataset.model_hash
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
}
|
||||
|
||||
function getSelectedModelHash() {
|
||||
//return the hash of the first selected model menu item
|
||||
try {
|
||||
return [...document.getElementsByClassName("mModelMenuItem")].filter(
|
||||
(e) => e.selected == true
|
||||
)[0].dataset.model_hash
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
//return the hash of the first selected model menu item
|
||||
try {
|
||||
return [...document.getElementsByClassName('mModelMenuItem')].filter(
|
||||
(e) => e.selected == true
|
||||
)[0].dataset.model_hash
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
}
|
||||
|
||||
function selectModelUi(model_hash) {
|
||||
model_element = getModelElementByHash(model_hash)
|
||||
model_element.selected = true
|
||||
model_element = getModelElementByHash(model_hash)
|
||||
model_element.selected = true
|
||||
}
|
||||
|
||||
function autoFillInModel(model_hash) {
|
||||
// unCheckAllSamplers()
|
||||
model_element = getModelElementByHash(model_hash)
|
||||
selectModelUi(model_hash)
|
||||
// model_element.
|
||||
const model_title = model_element.dataset.model_title
|
||||
return model_title
|
||||
// unCheckAllSamplers()
|
||||
model_element = getModelElementByHash(model_hash)
|
||||
selectModelUi(model_hash)
|
||||
// model_element.
|
||||
const model_title = model_element.dataset.model_title
|
||||
return model_title
|
||||
}
|
||||
////// End Models//////////
|
||||
|
||||
////// Start Init Image && Init Image Mask//////////
|
||||
|
||||
function getInitImageElement() {
|
||||
const ini_image_element = document.getElementById("init_image")
|
||||
return ini_image_element
|
||||
const ini_image_element = document.getElementById('init_image')
|
||||
return ini_image_element
|
||||
}
|
||||
function setInitImageSrc(image_src) {
|
||||
const ini_image_element = getInitImageElement()
|
||||
ini_image_element.src = image_src
|
||||
const ini_image_element = getInitImageElement()
|
||||
ini_image_element.src = image_src
|
||||
}
|
||||
|
||||
function getInitImageMaskElement() {
|
||||
const ini_image_mask_element = document.getElementById("init_image_mask")
|
||||
return ini_image_mask_element
|
||||
const ini_image_mask_element = document.getElementById('init_image_mask')
|
||||
return ini_image_mask_element
|
||||
}
|
||||
function setInitImageMaskSrc(image_src) {
|
||||
const ini_image_mask_element = getInitImageMaskElement()
|
||||
ini_image_mask_element.src = image_src
|
||||
const ini_image_mask_element = getInitImageMaskElement()
|
||||
ini_image_mask_element.src = image_src
|
||||
}
|
||||
////// End Init Image && Init Image Mask//////////
|
||||
|
||||
////// Start Generate Buttons //////////
|
||||
|
||||
function getGenerateButtonsElements() {
|
||||
generate_buttons = [...document.getElementsByClassName("btnGenerateClass")]
|
||||
return generate_buttons
|
||||
generate_buttons = [...document.getElementsByClassName('btnGenerateClass')]
|
||||
return generate_buttons
|
||||
}
|
||||
function setGenerateButtonsColor(addClassName, removeClassName) {
|
||||
const buttons = getGenerateButtonsElements()
|
||||
buttons.forEach((button) => {
|
||||
button.classList.add(addClassName)
|
||||
button.classList.remove(removeClassName)
|
||||
})
|
||||
const buttons = getGenerateButtonsElements()
|
||||
buttons.forEach((button) => {
|
||||
button.classList.add(addClassName)
|
||||
button.classList.remove(removeClassName)
|
||||
})
|
||||
}
|
||||
|
||||
////// End Generate Buttons //////////
|
||||
|
|
@ -331,225 +334,227 @@ function setGenerateButtonsColor(addClassName, removeClassName) {
|
|||
////// Start Servers Status //////////
|
||||
|
||||
function setAutomaticStatus(newStatusClass, oldStatusClass) {
|
||||
document.getElementById("automaticStatus").classList.add(newStatusClass)
|
||||
document.getElementById("automaticStatus").classList.remove(oldStatusClass)
|
||||
document.getElementById('automaticStatus').classList.add(newStatusClass)
|
||||
document.getElementById('automaticStatus').classList.remove(oldStatusClass)
|
||||
}
|
||||
function setProxyServerStatus(newStatusClass, oldStatusClass) {
|
||||
document.getElementById("proxyServerStatus").classList.add(newStatusClass)
|
||||
document.getElementById("proxyServerStatus").classList.remove(oldStatusClass)
|
||||
document.getElementById('proxyServerStatus').classList.add(newStatusClass)
|
||||
document
|
||||
.getElementById('proxyServerStatus')
|
||||
.classList.remove(oldStatusClass)
|
||||
}
|
||||
////// End Servers Status //////////
|
||||
|
||||
////// Start Reset Settings Button //////////
|
||||
|
||||
const defaultSettings = {
|
||||
model: null,
|
||||
prompt_shortcut: null,
|
||||
positive_prompt: "",
|
||||
negative_prompt: "",
|
||||
selection_mode: null,
|
||||
batch_number: 1,
|
||||
steps: 20,
|
||||
width: 512,
|
||||
height: 512,
|
||||
firstphase_width: 512,
|
||||
firstphase_height: 512,
|
||||
cfg: 7,
|
||||
denoising_strength: 0.7,
|
||||
hi_res_denoising_strength: 0.7,
|
||||
mask_blur: 8,
|
||||
inpaint_at_full_res: false,
|
||||
hi_res_fix: false,
|
||||
inpaint_padding: 0,
|
||||
seed: -1,
|
||||
samplers: null,
|
||||
mask_content: null,
|
||||
model: null,
|
||||
prompt_shortcut: null,
|
||||
positive_prompt: '',
|
||||
negative_prompt: '',
|
||||
selection_mode: null,
|
||||
batch_number: 1,
|
||||
steps: 20,
|
||||
width: 512,
|
||||
height: 512,
|
||||
firstphase_width: 512,
|
||||
firstphase_height: 512,
|
||||
cfg: 7,
|
||||
denoising_strength: 0.7,
|
||||
hi_res_denoising_strength: 0.7,
|
||||
mask_blur: 8,
|
||||
inpaint_at_full_res: false,
|
||||
hi_res_fix: false,
|
||||
inpaint_padding: 0,
|
||||
seed: -1,
|
||||
samplers: null,
|
||||
mask_content: null,
|
||||
}
|
||||
|
||||
document.getElementById("btnResetSettings").addEventListener("click", () => {
|
||||
autoFillDefaultSettings(defaultSettings)
|
||||
document.getElementById('btnResetSettings').addEventListener('click', () => {
|
||||
autoFillDefaultSettings(defaultSettings)
|
||||
})
|
||||
document.getElementById("btnSnapshot").addEventListener("click", async () => {
|
||||
await psapi.snapshot_layerExe()
|
||||
document.getElementById('btnSnapshot').addEventListener('click', async () => {
|
||||
await psapi.snapshot_layerExe()
|
||||
})
|
||||
|
||||
function getBatchNumber() {
|
||||
return document.getElementById("tiNumberOfImages").value
|
||||
return document.getElementById('tiNumberOfImages').value
|
||||
}
|
||||
function autoFillInBatchNumber(batch_number) {
|
||||
document.getElementById("tiNumberOfImages").value = String(batch_number)
|
||||
document.getElementById('tiNumberOfImages').value = String(batch_number)
|
||||
}
|
||||
|
||||
function getSteps() {
|
||||
return document.getElementById("tiNumberOfSteps").value
|
||||
return document.getElementById('tiNumberOfSteps').value
|
||||
}
|
||||
function autoFillInSteps(steps) {
|
||||
document.getElementById("tiNumberOfSteps").value = String(steps)
|
||||
document.getElementById('tiNumberOfSteps').value = String(steps)
|
||||
}
|
||||
function autoFillDefaultSettings(default_settings) {
|
||||
autoFillSettings(default_settings)
|
||||
autoFillSettings(default_settings)
|
||||
}
|
||||
|
||||
function setCFG(cfg_value) {
|
||||
document.getElementById("slCfgScale").value = cfg_value
|
||||
document.getElementById('slCfgScale').value = cfg_value
|
||||
}
|
||||
function getCFG() {
|
||||
return document.getElementById("slCfgScale").value
|
||||
return document.getElementById('slCfgScale').value
|
||||
}
|
||||
|
||||
function autoFillSettings(settings) {
|
||||
try {
|
||||
//reset all UI settings except model selection and sampler selection
|
||||
autoFillInPrompt(settings["positive_prompt"])
|
||||
autoFillInNegativePrompt(settings["negative_prompt"])
|
||||
autoFillInBatchNumber(settings["batch_number"])
|
||||
autoFillInSteps(settings["steps"])
|
||||
autoFillInWidth(settings["width"])
|
||||
autoFillInHeight(settings["height"])
|
||||
autoFillInHiResFixs(
|
||||
settings["firstphase_width"],
|
||||
settings["firstphase_height"]
|
||||
)
|
||||
document.getElementById("slCfgScale").value = settings["cfg"]
|
||||
autoFillInDenoisingStrength(settings["denoising_strength"])
|
||||
autoFillInSliderUi(
|
||||
settings["hi_res_denoising_strength"],
|
||||
"hrDenoisingStrength",
|
||||
"hDenoisingStrength",
|
||||
100
|
||||
)
|
||||
document.getElementById("slMaskBlur").value = settings["mask_blur"]
|
||||
document.getElementById("chInpaintFullRes").checked =
|
||||
settings["inpaint_at_full_res"]
|
||||
setHiResFixs(settings["hi_res_fix"])
|
||||
document.getElementById("tiSeed").value = String(settings["seed"])
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
try {
|
||||
//reset all UI settings except model selection and sampler selection
|
||||
autoFillInPrompt(settings['positive_prompt'])
|
||||
autoFillInNegativePrompt(settings['negative_prompt'])
|
||||
autoFillInBatchNumber(settings['batch_number'])
|
||||
autoFillInSteps(settings['steps'])
|
||||
autoFillInWidth(settings['width'])
|
||||
autoFillInHeight(settings['height'])
|
||||
autoFillInHiResFixs(
|
||||
settings['firstphase_width'],
|
||||
settings['firstphase_height']
|
||||
)
|
||||
document.getElementById('slCfgScale').value = settings['cfg']
|
||||
autoFillInDenoisingStrength(settings['denoising_strength'])
|
||||
autoFillInSliderUi(
|
||||
settings['hi_res_denoising_strength'],
|
||||
'hrDenoisingStrength',
|
||||
'hDenoisingStrength',
|
||||
100
|
||||
)
|
||||
document.getElementById('slMaskBlur').value = settings['mask_blur']
|
||||
document.getElementById('chInpaintFullRes').checked =
|
||||
settings['inpaint_at_full_res']
|
||||
setHiResFixs(settings['hi_res_fix'])
|
||||
document.getElementById('tiSeed').value = String(settings['seed'])
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
}
|
||||
////// End Reset Settings Button //////////
|
||||
|
||||
function getMaskBlur() {
|
||||
const isDisabled = document
|
||||
.getElementById("slMaskBlur")
|
||||
.hasAttribute("disabled")
|
||||
let mask_blur = 0
|
||||
if (isDisabled) {
|
||||
mask_blur = 0
|
||||
} else {
|
||||
mask_blur = document.getElementById("slMaskBlur").value
|
||||
}
|
||||
return mask_blur
|
||||
const isDisabled = document
|
||||
.getElementById('slMaskBlur')
|
||||
.hasAttribute('disabled')
|
||||
let mask_blur = 0
|
||||
if (isDisabled) {
|
||||
mask_blur = 0
|
||||
} else {
|
||||
mask_blur = document.getElementById('slMaskBlur').value
|
||||
}
|
||||
return mask_blur
|
||||
}
|
||||
function getUseSharpMask() {
|
||||
const isChecked = document.getElementById("chUseSharpMask").checked
|
||||
return isChecked
|
||||
const isChecked = document.getElementById('chUseSharpMask').checked
|
||||
return isChecked
|
||||
}
|
||||
document.getElementById("chUseSharpMask").addEventListener("change", (ev) => {
|
||||
const isChecked = ev.target.checked
|
||||
if (isChecked) {
|
||||
document.getElementById("slMaskBlur").setAttribute("disabled")
|
||||
} else {
|
||||
document.getElementById("slMaskBlur").removeAttribute("disabled")
|
||||
}
|
||||
document.getElementById('chUseSharpMask').addEventListener('change', (ev) => {
|
||||
const isChecked = ev.target.checked
|
||||
if (isChecked) {
|
||||
document.getElementById('slMaskBlur').setAttribute('disabled')
|
||||
} else {
|
||||
document.getElementById('slMaskBlur').removeAttribute('disabled')
|
||||
}
|
||||
})
|
||||
|
||||
document.getElementById("chUseSmartObject").addEventListener("change", (ev) => {
|
||||
const isChecked = ev.target.checked
|
||||
if (isChecked) {
|
||||
g_b_use_smart_object = true
|
||||
} else {
|
||||
g_b_use_smart_object = false
|
||||
}
|
||||
document.getElementById('chUseSmartObject').addEventListener('change', (ev) => {
|
||||
const isChecked = ev.target.checked
|
||||
if (isChecked) {
|
||||
g_b_use_smart_object = true
|
||||
} else {
|
||||
g_b_use_smart_object = false
|
||||
}
|
||||
})
|
||||
|
||||
function getPromptShortcut() {
|
||||
//read json string
|
||||
//converted into json object
|
||||
const prompt_shortcut_string =
|
||||
document.getElementById("taPromptShortcut").value
|
||||
const prompt_shortcut = JSON.parse(prompt_shortcut_string)
|
||||
return prompt_shortcut
|
||||
//read json string
|
||||
//converted into json object
|
||||
const prompt_shortcut_string =
|
||||
document.getElementById('taPromptShortcut').value
|
||||
const prompt_shortcut = JSON.parse(prompt_shortcut_string)
|
||||
return prompt_shortcut
|
||||
}
|
||||
function setPromptShortcut(prompt_shortcut) {
|
||||
//prompt_shortcut is json object
|
||||
//convert it into pretty json string and save it in the prompt shortcut textarea
|
||||
var JSONInPrettyFormat = JSON.stringify(prompt_shortcut, undefined, 7)
|
||||
document.getElementById("taPromptShortcut").value = JSONInPrettyFormat
|
||||
//prompt_shortcut is json object
|
||||
//convert it into pretty json string and save it in the prompt shortcut textarea
|
||||
var JSONInPrettyFormat = JSON.stringify(prompt_shortcut, undefined, 7)
|
||||
document.getElementById('taPromptShortcut').value = JSONInPrettyFormat
|
||||
}
|
||||
|
||||
////start selection mode/////
|
||||
function getSelectionMode() {
|
||||
return [...document.getElementsByClassName("rbSelectionMode")].filter(
|
||||
(e) => e.checked == true
|
||||
)[0].value
|
||||
return [...document.getElementsByClassName('rbSelectionMode')].filter(
|
||||
(e) => e.checked == true
|
||||
)[0].value
|
||||
}
|
||||
function getMaskContent() {
|
||||
return [...document.getElementsByClassName("rbMaskContent")].filter(
|
||||
(e) => e.checked == true
|
||||
)[0].value
|
||||
return [...document.getElementsByClassName('rbMaskContent')].filter(
|
||||
(e) => e.checked == true
|
||||
)[0].value
|
||||
}
|
||||
function setMaskContent(value) {
|
||||
try {
|
||||
//assume the sampler_name is valid
|
||||
//return the first
|
||||
//convert htmlCollection into an array, then user filter to get the radio button with the value equals to sampler_name
|
||||
const mask_content_element = [
|
||||
...document.getElementsByClassName("rbMaskContent"),
|
||||
].filter((e) => e.value == value)[0]
|
||||
mask_content_element.checked = true
|
||||
return mask_content_element
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
try {
|
||||
//assume the sampler_name is valid
|
||||
//return the first
|
||||
//convert htmlCollection into an array, then user filter to get the radio button with the value equals to sampler_name
|
||||
const mask_content_element = [
|
||||
...document.getElementsByClassName('rbMaskContent'),
|
||||
].filter((e) => e.value == value)[0]
|
||||
mask_content_element.checked = true
|
||||
return mask_content_element
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
}
|
||||
|
||||
///end selection mode////
|
||||
module.exports = {
|
||||
getPrompt,
|
||||
autoFillInPrompt,
|
||||
getNegativePrompt,
|
||||
autoFillInNegativePrompt,
|
||||
getDenoisingStrength,
|
||||
autoFillInDenoisingStrength,
|
||||
getWidth,
|
||||
autoFillInWidth,
|
||||
getHeight,
|
||||
autoFillInHeight,
|
||||
getSliderSdValue,
|
||||
autoFillInHiResFixs,
|
||||
getHiResFixs,
|
||||
setHiResFixs,
|
||||
autoFillInSliderUi,
|
||||
getCheckedSamplerName,
|
||||
autoFillInSampler,
|
||||
autoFillInModel,
|
||||
getMode,
|
||||
setInitImageSrc,
|
||||
setInitImageMaskSrc,
|
||||
setGenerateButtonsColor,
|
||||
setAutomaticStatus,
|
||||
setProxyServerStatus,
|
||||
defaultSettings,
|
||||
autoFillDefaultSettings,
|
||||
autoFillSettings,
|
||||
getMaskBlur,
|
||||
getUseSharpMask,
|
||||
autoFillInHRHeight,
|
||||
autoFillInHRWidth,
|
||||
getPromptShortcut,
|
||||
setPromptShortcut,
|
||||
getModelHashByTitle,
|
||||
getSelectionMode,
|
||||
autoFillInInpaintMaskWeight,
|
||||
autoFillInSteps,
|
||||
getSteps,
|
||||
getBatchNumber,
|
||||
autoFillInBatchNumber,
|
||||
getHrWidth,
|
||||
getHrHeight,
|
||||
setCFG,
|
||||
getCFG,
|
||||
getMaskContent,
|
||||
setMaskContent,
|
||||
getPrompt,
|
||||
autoFillInPrompt,
|
||||
getNegativePrompt,
|
||||
autoFillInNegativePrompt,
|
||||
getDenoisingStrength,
|
||||
autoFillInDenoisingStrength,
|
||||
getWidth,
|
||||
autoFillInWidth,
|
||||
getHeight,
|
||||
autoFillInHeight,
|
||||
getSliderSdValue,
|
||||
autoFillInHiResFixs,
|
||||
getHiResFixs,
|
||||
setHiResFixs,
|
||||
autoFillInSliderUi,
|
||||
getCheckedSamplerName,
|
||||
autoFillInSampler,
|
||||
autoFillInModel,
|
||||
getMode,
|
||||
setInitImageSrc,
|
||||
setInitImageMaskSrc,
|
||||
setGenerateButtonsColor,
|
||||
setAutomaticStatus,
|
||||
setProxyServerStatus,
|
||||
defaultSettings,
|
||||
autoFillDefaultSettings,
|
||||
autoFillSettings,
|
||||
getMaskBlur,
|
||||
getUseSharpMask,
|
||||
autoFillInHRHeight,
|
||||
autoFillInHRWidth,
|
||||
getPromptShortcut,
|
||||
setPromptShortcut,
|
||||
getModelHashByTitle,
|
||||
getSelectionMode,
|
||||
autoFillInInpaintMaskWeight,
|
||||
autoFillInSteps,
|
||||
getSteps,
|
||||
getBatchNumber,
|
||||
autoFillInBatchNumber,
|
||||
getHrWidth,
|
||||
getHrHeight,
|
||||
setCFG,
|
||||
getCFG,
|
||||
getMaskContent,
|
||||
setMaskContent,
|
||||
}
|
||||
|
|
|
|||
166
utility/layer.js
166
utility/layer.js
|
|
@ -1,110 +1,110 @@
|
|||
const { batchPlay } = require("photoshop").action
|
||||
const { executeAsModal } = require("photoshop").core
|
||||
const { cleanLayers, getLayerIndex, selectLayers } = require("../psapi")
|
||||
const { batchPlay } = require('photoshop').action
|
||||
const { executeAsModal } = require('photoshop').core
|
||||
const { cleanLayers, getLayerIndex, selectLayers } = require('../psapi')
|
||||
|
||||
async function createNewLayerExe(layerName) {
|
||||
await executeAsModal(async () => {
|
||||
await createNewLayerCommand(layerName)
|
||||
})
|
||||
const new_layer = await app.activeDocument.activeLayers[0]
|
||||
return new_layer
|
||||
await executeAsModal(async () => {
|
||||
await createNewLayerCommand(layerName)
|
||||
})
|
||||
const new_layer = await app.activeDocument.activeLayers[0]
|
||||
return new_layer
|
||||
}
|
||||
|
||||
async function createNewLayerCommand(layerName) {
|
||||
return await app.activeDocument.createLayer({
|
||||
name: layerName,
|
||||
opacity: 100,
|
||||
mode: "normal",
|
||||
})
|
||||
return await app.activeDocument.createLayer({
|
||||
name: layerName,
|
||||
opacity: 100,
|
||||
mode: 'normal',
|
||||
})
|
||||
}
|
||||
|
||||
async function deleteLayers(layers) {
|
||||
try {
|
||||
await cleanLayers(layers)
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
try {
|
||||
await cleanLayers(layers)
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
}
|
||||
|
||||
async function getIndexCommand() {
|
||||
const command = {
|
||||
_obj: "get",
|
||||
_target: [
|
||||
{
|
||||
_property: "itemIndex",
|
||||
},
|
||||
{
|
||||
_ref: "layer",
|
||||
_enum: "ordinal",
|
||||
_value: "targetEnum",
|
||||
},
|
||||
],
|
||||
}
|
||||
const result = await batchPlay([command], {
|
||||
synchronousExecution: true,
|
||||
modalBehavior: "execute",
|
||||
})
|
||||
const command = {
|
||||
_obj: 'get',
|
||||
_target: [
|
||||
{
|
||||
_property: 'itemIndex',
|
||||
},
|
||||
{
|
||||
_ref: 'layer',
|
||||
_enum: 'ordinal',
|
||||
_value: 'targetEnum',
|
||||
},
|
||||
],
|
||||
}
|
||||
const result = await batchPlay([command], {
|
||||
synchronousExecution: true,
|
||||
modalBehavior: 'execute',
|
||||
})
|
||||
|
||||
return result
|
||||
return result
|
||||
}
|
||||
|
||||
async function getIndexExe() {
|
||||
let index
|
||||
await executeAsModal(async () => {
|
||||
index = await getIndexCommand()
|
||||
})
|
||||
let index
|
||||
await executeAsModal(async () => {
|
||||
index = await getIndexCommand()
|
||||
})
|
||||
|
||||
return index
|
||||
return index
|
||||
}
|
||||
const photoshop = require("photoshop")
|
||||
const photoshop = require('photoshop')
|
||||
|
||||
const collapseFolderCommand = async (expand = false, recursive = false) => {
|
||||
let result
|
||||
try {
|
||||
result = await batchPlay(
|
||||
[
|
||||
{
|
||||
_obj: "set",
|
||||
_target: {
|
||||
_ref: [
|
||||
{ _property: "layerSectionExpanded" },
|
||||
{
|
||||
_ref: "layer",
|
||||
_enum: "ordinal",
|
||||
_value: "targetEnum",
|
||||
},
|
||||
let result
|
||||
try {
|
||||
result = await batchPlay(
|
||||
[
|
||||
{
|
||||
_obj: 'set',
|
||||
_target: {
|
||||
_ref: [
|
||||
{ _property: 'layerSectionExpanded' },
|
||||
{
|
||||
_ref: 'layer',
|
||||
_enum: 'ordinal',
|
||||
_value: 'targetEnum',
|
||||
},
|
||||
],
|
||||
},
|
||||
to: expand,
|
||||
recursive,
|
||||
_options: { dialogOptions: 'dontDisplay' },
|
||||
},
|
||||
],
|
||||
},
|
||||
to: expand,
|
||||
recursive,
|
||||
_options: { dialogOptions: "dontDisplay" },
|
||||
},
|
||||
],
|
||||
{ synchronousExecution: true }
|
||||
)
|
||||
} catch (e) {
|
||||
console.error(e.message)
|
||||
}
|
||||
return result
|
||||
{ synchronousExecution: true }
|
||||
)
|
||||
} catch (e) {
|
||||
console.error(e.message)
|
||||
}
|
||||
return result
|
||||
}
|
||||
async function collapseFolderExe(layers, expand = false, recursive = false) {
|
||||
for (let layer of layers) {
|
||||
try {
|
||||
await executeAsModal(async () => {
|
||||
const is_visible = await layer.visible // don't change the visiblity of the layer when collapsing
|
||||
await selectLayers([layer])
|
||||
await collapseFolderCommand(expand, recursive)
|
||||
layer.visible = is_visible
|
||||
})
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
for (let layer of layers) {
|
||||
try {
|
||||
await executeAsModal(async () => {
|
||||
const is_visible = await layer.visible // don't change the visiblity of the layer when collapsing
|
||||
await selectLayers([layer])
|
||||
await collapseFolderCommand(expand, recursive)
|
||||
layer.visible = is_visible
|
||||
})
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
createNewLayerExe,
|
||||
deleteLayers,
|
||||
getIndexExe,
|
||||
collapseFolderExe,
|
||||
createNewLayerExe,
|
||||
deleteLayers,
|
||||
getIndexExe,
|
||||
collapseFolderExe,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,109 +1,109 @@
|
|||
let settings = {
|
||||
model: null,
|
||||
prompt_shortcut: null,
|
||||
positive_prompt: null,
|
||||
negative_prompt: null,
|
||||
selection_mode: null,
|
||||
batch_number: null,
|
||||
steps: null,
|
||||
width: null,
|
||||
height: null,
|
||||
firstphase_width: null,
|
||||
firstphase_height: null,
|
||||
cfg: null,
|
||||
denoising_strength: null,
|
||||
hi_res_denoising_strength: null,
|
||||
mask_blur: null,
|
||||
inpaint_at_full_res: null,
|
||||
hi_res_fix: null,
|
||||
inpaint_padding: null,
|
||||
seed: null,
|
||||
samplers: null,
|
||||
mask_content: null,
|
||||
model: null,
|
||||
prompt_shortcut: null,
|
||||
positive_prompt: null,
|
||||
negative_prompt: null,
|
||||
selection_mode: null,
|
||||
batch_number: null,
|
||||
steps: null,
|
||||
width: null,
|
||||
height: null,
|
||||
firstphase_width: null,
|
||||
firstphase_height: null,
|
||||
cfg: null,
|
||||
denoising_strength: null,
|
||||
hi_res_denoising_strength: null,
|
||||
mask_blur: null,
|
||||
inpaint_at_full_res: null,
|
||||
hi_res_fix: null,
|
||||
inpaint_padding: null,
|
||||
seed: null,
|
||||
samplers: null,
|
||||
mask_content: null,
|
||||
}
|
||||
|
||||
let LatentNoiseSettings = {
|
||||
model: null,
|
||||
prompt_shortcut: null,
|
||||
positive_prompt: null,
|
||||
negative_prompt: null,
|
||||
generation_mode: null,
|
||||
batch_number: null,
|
||||
steps: null,
|
||||
width: null,
|
||||
height: null,
|
||||
firstphase_width: null,
|
||||
firstphase_height: null,
|
||||
cfg: null,
|
||||
denoising_strength: 0.92,
|
||||
hi_res_denoising_strength: null,
|
||||
mask_blur: null,
|
||||
inpaint_at_full_res: null,
|
||||
hi_res_fix: null,
|
||||
inpaint_padding: null,
|
||||
seed: null,
|
||||
samplers: null,
|
||||
mask_content: "2",
|
||||
model: null,
|
||||
prompt_shortcut: null,
|
||||
positive_prompt: null,
|
||||
negative_prompt: null,
|
||||
generation_mode: null,
|
||||
batch_number: null,
|
||||
steps: null,
|
||||
width: null,
|
||||
height: null,
|
||||
firstphase_width: null,
|
||||
firstphase_height: null,
|
||||
cfg: null,
|
||||
denoising_strength: 0.92,
|
||||
hi_res_denoising_strength: null,
|
||||
mask_blur: null,
|
||||
inpaint_at_full_res: null,
|
||||
hi_res_fix: null,
|
||||
inpaint_padding: null,
|
||||
seed: null,
|
||||
samplers: null,
|
||||
mask_content: '2',
|
||||
}
|
||||
|
||||
let FillSettings = {
|
||||
model: null,
|
||||
prompt_shortcut: null,
|
||||
positive_prompt: null,
|
||||
negative_prompt: null,
|
||||
generation_mode: null,
|
||||
batch_number: null,
|
||||
steps: null,
|
||||
width: null,
|
||||
height: null,
|
||||
firstphase_width: null,
|
||||
firstphase_height: null,
|
||||
cfg: null,
|
||||
denoising_strength: 0.7,
|
||||
hi_res_denoising_strength: null,
|
||||
mask_blur: null,
|
||||
inpaint_at_full_res: null,
|
||||
hi_res_fix: null,
|
||||
inpaint_padding: null,
|
||||
seed: null,
|
||||
samplers: null,
|
||||
mask_content: "0",
|
||||
model: null,
|
||||
prompt_shortcut: null,
|
||||
positive_prompt: null,
|
||||
negative_prompt: null,
|
||||
generation_mode: null,
|
||||
batch_number: null,
|
||||
steps: null,
|
||||
width: null,
|
||||
height: null,
|
||||
firstphase_width: null,
|
||||
firstphase_height: null,
|
||||
cfg: null,
|
||||
denoising_strength: 0.7,
|
||||
hi_res_denoising_strength: null,
|
||||
mask_blur: null,
|
||||
inpaint_at_full_res: null,
|
||||
hi_res_fix: null,
|
||||
inpaint_padding: null,
|
||||
seed: null,
|
||||
samplers: null,
|
||||
mask_content: '0',
|
||||
}
|
||||
let OriginalSettings = {
|
||||
model: null,
|
||||
prompt_shortcut: null,
|
||||
positive_prompt: null,
|
||||
negative_prompt: null,
|
||||
generation_mode: null,
|
||||
batch_number: null,
|
||||
steps: null,
|
||||
width: null,
|
||||
height: null,
|
||||
firstphase_width: null,
|
||||
firstphase_height: null,
|
||||
cfg: null,
|
||||
denoising_strength: 0.7,
|
||||
hi_res_denoising_strength: null,
|
||||
mask_blur: null,
|
||||
inpaint_at_full_res: null,
|
||||
hi_res_fix: null,
|
||||
inpaint_padding: null,
|
||||
seed: null,
|
||||
samplers: null,
|
||||
mask_content: "1",
|
||||
model: null,
|
||||
prompt_shortcut: null,
|
||||
positive_prompt: null,
|
||||
negative_prompt: null,
|
||||
generation_mode: null,
|
||||
batch_number: null,
|
||||
steps: null,
|
||||
width: null,
|
||||
height: null,
|
||||
firstphase_width: null,
|
||||
firstphase_height: null,
|
||||
cfg: null,
|
||||
denoising_strength: 0.7,
|
||||
hi_res_denoising_strength: null,
|
||||
mask_blur: null,
|
||||
inpaint_at_full_res: null,
|
||||
hi_res_fix: null,
|
||||
inpaint_padding: null,
|
||||
seed: null,
|
||||
samplers: null,
|
||||
mask_content: '1',
|
||||
}
|
||||
|
||||
function nullAllSettings() {}
|
||||
|
||||
class Preset {
|
||||
constructor() {}
|
||||
constructor() {}
|
||||
|
||||
loadPresetFromJson(preset_path) {}
|
||||
savePresetToJson(preset_path, settings) {}
|
||||
loadPresetFromJson(preset_path) {}
|
||||
savePresetToJson(preset_path, settings) {}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
LatentNoiseSettings,
|
||||
FillSettings,
|
||||
OriginalSettings,
|
||||
LatentNoiseSettings,
|
||||
FillSettings,
|
||||
OriginalSettings,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,103 +1,105 @@
|
|||
async function requestModelsHorde() {
|
||||
//get the models list from url
|
||||
// https://stablehorde.net/api/v2/status/models
|
||||
//get the models list from url
|
||||
// https://stablehorde.net/api/v2/status/models
|
||||
|
||||
console.log("requestModelsHorde: ")
|
||||
console.log('requestModelsHorde: ')
|
||||
|
||||
const full_url = "https://stablehorde.net/api/v2/status/models"
|
||||
let request = await fetch(full_url)
|
||||
let json = await request.json()
|
||||
console.log("hordes models json:")
|
||||
console.dir(json)
|
||||
const full_url = 'https://stablehorde.net/api/v2/status/models'
|
||||
let request = await fetch(full_url)
|
||||
let json = await request.json()
|
||||
console.log('hordes models json:')
|
||||
console.dir(json)
|
||||
|
||||
return json
|
||||
return json
|
||||
}
|
||||
|
||||
function addHordeModelMenuItem(model_title, model_name) {
|
||||
// console.log(model_title,model_name)
|
||||
const menu_item_element = document.createElement("sp-menu-item")
|
||||
menu_item_element.className = "mModelMenuItemHorde"
|
||||
menu_item_element.innerHTML = model_title
|
||||
// console.log(model_title,model_name)
|
||||
const menu_item_element = document.createElement('sp-menu-item')
|
||||
menu_item_element.className = 'mModelMenuItemHorde'
|
||||
menu_item_element.innerHTML = model_title
|
||||
|
||||
menu_item_element.dataset.name = model_name
|
||||
return menu_item_element
|
||||
menu_item_element.dataset.name = model_name
|
||||
return menu_item_element
|
||||
}
|
||||
|
||||
async function refreshModelsHorde() {
|
||||
try {
|
||||
let g_models_horde = await requestModelsHorde()
|
||||
// const models_menu_element = document.getElementById('mModelsMenu')
|
||||
// models_menu_element.value = ""
|
||||
//(optional): sort the models
|
||||
try {
|
||||
let g_models_horde = await requestModelsHorde()
|
||||
// const models_menu_element = document.getElementById('mModelsMenu')
|
||||
// models_menu_element.value = ""
|
||||
//(optional): sort the models
|
||||
|
||||
g_models_horde.sort(function (a, b) {
|
||||
return b.count - a.count
|
||||
})
|
||||
// g_models_horde = g_models_horde.sort( compareModelCounts );
|
||||
document.getElementById("mModelsMenuHorde").innerHTML = ""
|
||||
let model_item_random = addHordeModelMenuItem("Random", "Random")
|
||||
model_item_random.selected = true
|
||||
document.getElementById("mModelsMenuHorde").appendChild(model_item_random)
|
||||
for (let model of g_models_horde) {
|
||||
console.log(model.name, model.count)
|
||||
const model_html_tile = `${model.name}: ${model.count}`
|
||||
const model_item_element = addHordeModelMenuItem(
|
||||
model_html_tile,
|
||||
model.name
|
||||
)
|
||||
g_models_horde.sort(function (a, b) {
|
||||
return b.count - a.count
|
||||
})
|
||||
// g_models_horde = g_models_horde.sort( compareModelCounts );
|
||||
document.getElementById('mModelsMenuHorde').innerHTML = ''
|
||||
let model_item_random = addHordeModelMenuItem('Random', 'Random')
|
||||
model_item_random.selected = true
|
||||
document
|
||||
.getElementById('mModelsMenuHorde')
|
||||
.appendChild(model_item_random)
|
||||
for (let model of g_models_horde) {
|
||||
console.log(model.name, model.count)
|
||||
const model_html_tile = `${model.name}: ${model.count}`
|
||||
const model_item_element = addHordeModelMenuItem(
|
||||
model_html_tile,
|
||||
model.name
|
||||
)
|
||||
|
||||
document
|
||||
.getElementById("mModelsMenuHorde")
|
||||
.appendChild(model_item_element)
|
||||
document
|
||||
.getElementById('mModelsMenuHorde')
|
||||
.appendChild(model_item_element)
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
}
|
||||
function getModelHorde() {
|
||||
return [...document.getElementsByClassName("mModelMenuItemHorde")].filter(
|
||||
(e) => e.selected == true
|
||||
)[0].dataset.name
|
||||
return [...document.getElementsByClassName('mModelMenuItemHorde')].filter(
|
||||
(e) => e.selected == true
|
||||
)[0].dataset.name
|
||||
}
|
||||
function getUseHorde() {
|
||||
const isChecked = document.getElementById("chUseHorde").checked
|
||||
return isChecked
|
||||
const isChecked = document.getElementById('chUseHorde').checked
|
||||
return isChecked
|
||||
}
|
||||
function getScriptArgs() {
|
||||
const model = getModelHorde()
|
||||
const b_nsfw = document.getElementById("chUseNSFW").checked
|
||||
const b_shared_laion = document.getElementById("chUseSharedLaion").checked
|
||||
const model = getModelHorde()
|
||||
const b_nsfw = document.getElementById('chUseNSFW').checked
|
||||
const b_shared_laion = document.getElementById('chUseSharedLaion').checked
|
||||
|
||||
let seed_variation = document.getElementById("slSeedVariation").value
|
||||
seed_variation = parseInt(seed_variation)
|
||||
const script_args_json = {
|
||||
model: model,
|
||||
nsfw: b_nsfw,
|
||||
shared_laion: b_shared_laion,
|
||||
seed_variation: seed_variation,
|
||||
post_processing_1: "None",
|
||||
post_processing_2: "None",
|
||||
post_processing_3: "None",
|
||||
}
|
||||
const script_args = Object.values(script_args_json)
|
||||
return script_args
|
||||
let seed_variation = document.getElementById('slSeedVariation').value
|
||||
seed_variation = parseInt(seed_variation)
|
||||
const script_args_json = {
|
||||
model: model,
|
||||
nsfw: b_nsfw,
|
||||
shared_laion: b_shared_laion,
|
||||
seed_variation: seed_variation,
|
||||
post_processing_1: 'None',
|
||||
post_processing_2: 'None',
|
||||
post_processing_3: 'None',
|
||||
}
|
||||
const script_args = Object.values(script_args_json)
|
||||
return script_args
|
||||
}
|
||||
|
||||
document
|
||||
.getElementById("btnRefreshModelsHorde")
|
||||
.addEventListener("click", async () => {
|
||||
await refreshModelsHorde()
|
||||
})
|
||||
.getElementById('btnRefreshModelsHorde')
|
||||
.addEventListener('click', async () => {
|
||||
await refreshModelsHorde()
|
||||
})
|
||||
|
||||
const script_name = "Run on Stable Horde"
|
||||
const script_name = 'Run on Stable Horde'
|
||||
|
||||
refreshModelsHorde() //refresh the model when importing the script
|
||||
|
||||
module.exports = {
|
||||
requestModelsHorde,
|
||||
refreshModelsHorde,
|
||||
getModelHorde,
|
||||
getUseHorde,
|
||||
getScriptArgs,
|
||||
script_name,
|
||||
requestModelsHorde,
|
||||
refreshModelsHorde,
|
||||
getModelHorde,
|
||||
getUseHorde,
|
||||
getScriptArgs,
|
||||
script_name,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,43 +1,43 @@
|
|||
const sdapi = require("../../sdapi")
|
||||
const sdapi = require('../../sdapi')
|
||||
|
||||
class SdConfig {
|
||||
constructor() {
|
||||
this.config //store sd options
|
||||
}
|
||||
|
||||
async getConfig() {
|
||||
try {
|
||||
this.config = await sdapi.requestGetConfig()
|
||||
return this.config
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
constructor() {
|
||||
this.config //store sd options
|
||||
}
|
||||
}
|
||||
getUpscalerModels() {
|
||||
try {
|
||||
// const upscaler_comp = this.config.components.filter(comp =>comp.props.elem_id === "txt2img_hr_upscaler")[0]
|
||||
let upscaler_comp
|
||||
console.log("this.config: ", this.config)
|
||||
for (let comp of this.config.components) {
|
||||
if (comp?.props?.elem_id) {
|
||||
const elem_id = comp?.props?.elem_id
|
||||
if (elem_id === "txt2img_hr_upscaler") {
|
||||
console.log("elem_id: ", elem_id)
|
||||
upscaler_comp = comp
|
||||
break
|
||||
}
|
||||
|
||||
async getConfig() {
|
||||
try {
|
||||
this.config = await sdapi.requestGetConfig()
|
||||
return this.config
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
}
|
||||
getUpscalerModels() {
|
||||
try {
|
||||
// const upscaler_comp = this.config.components.filter(comp =>comp.props.elem_id === "txt2img_hr_upscaler")[0]
|
||||
let upscaler_comp
|
||||
console.log('this.config: ', this.config)
|
||||
for (let comp of this.config.components) {
|
||||
if (comp?.props?.elem_id) {
|
||||
const elem_id = comp?.props?.elem_id
|
||||
if (elem_id === 'txt2img_hr_upscaler') {
|
||||
console.log('elem_id: ', elem_id)
|
||||
upscaler_comp = comp
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log('upscaler_comp: ', upscaler_comp)
|
||||
const upscalers = upscaler_comp.props.choices
|
||||
|
||||
return upscalers
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
}
|
||||
console.log("upscaler_comp: ", upscaler_comp)
|
||||
const upscalers = upscaler_comp.props.choices
|
||||
|
||||
return upscalers
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
SdConfig,
|
||||
SdConfig,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,39 +1,39 @@
|
|||
const sdapi = require("../../sdapi")
|
||||
const sdapi = require('../../sdapi')
|
||||
|
||||
class SdOptions {
|
||||
constructor() {
|
||||
// this.status = false // true if we have a valid copy of sd options, false otherwise
|
||||
this.options //store sd options
|
||||
}
|
||||
|
||||
async getOptions() {
|
||||
try {
|
||||
// if (this.status) {
|
||||
// return this.options
|
||||
// } else {
|
||||
// this.options = await sdapi.requestGetOptions()
|
||||
// if (this.options) {
|
||||
// this.status = true
|
||||
// }
|
||||
// }
|
||||
this.options = await sdapi.requestGetOptions()
|
||||
return this.options
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
constructor() {
|
||||
// this.status = false // true if we have a valid copy of sd options, false otherwise
|
||||
this.options //store sd options
|
||||
}
|
||||
|
||||
async getOptions() {
|
||||
try {
|
||||
// if (this.status) {
|
||||
// return this.options
|
||||
// } else {
|
||||
// this.options = await sdapi.requestGetOptions()
|
||||
// if (this.options) {
|
||||
// this.status = true
|
||||
// }
|
||||
// }
|
||||
this.options = await sdapi.requestGetOptions()
|
||||
return this.options
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
}
|
||||
getCurrentModel() {
|
||||
const current_model = this.options?.sd_model_checkpoint
|
||||
return current_model
|
||||
}
|
||||
getInpaintingMaskWeight() {
|
||||
const inpainting_mask_weight = this.options?.inpainting_mask_weight
|
||||
return inpainting_mask_weight
|
||||
}
|
||||
}
|
||||
getCurrentModel() {
|
||||
const current_model = this.options?.sd_model_checkpoint
|
||||
return current_model
|
||||
}
|
||||
getInpaintingMaskWeight() {
|
||||
const inpainting_mask_weight = this.options?.inpainting_mask_weight
|
||||
return inpainting_mask_weight
|
||||
}
|
||||
}
|
||||
// const sd_options = new SdOptions()
|
||||
// sd_options.option?.sd_model_checkpoint
|
||||
|
||||
module.exports = {
|
||||
SdOptions,
|
||||
SdOptions,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,148 +1,153 @@
|
|||
const { cleanLayers } = require("../psapi")
|
||||
const { cleanLayers } = require('../psapi')
|
||||
|
||||
const SessionState = {
|
||||
Active: "active",
|
||||
Inactive: "inactive",
|
||||
Active: 'active',
|
||||
Inactive: 'inactive',
|
||||
}
|
||||
const GarbageCollectionState = {
|
||||
Accept: "accept", // accept all generated images
|
||||
Discard: "discard", //discard all generated images
|
||||
DiscardSelected: "discard_selected",
|
||||
AcceptSelected: "accept_selected", //accept_selected only chosen images
|
||||
Accept: 'accept', // accept all generated images
|
||||
Discard: 'discard', //discard all generated images
|
||||
DiscardSelected: 'discard_selected',
|
||||
AcceptSelected: 'accept_selected', //accept_selected only chosen images
|
||||
}
|
||||
|
||||
class GenerationSession {
|
||||
constructor() {
|
||||
//this should be unique session id and it also should act as the total number of sessions been created in the project
|
||||
this.id = 0
|
||||
this.state = SessionState["Inactive"]
|
||||
this.mode = "txt2img"
|
||||
this.selectionInfo = null
|
||||
this.isFirstGeneration = true // only before the first generation is requested should this be true
|
||||
this.outputGroup
|
||||
this.prevOutputGroup
|
||||
this.isLoadingActive = false
|
||||
}
|
||||
isActive() {
|
||||
return this.state === SessionState["Active"]
|
||||
}
|
||||
isInactive() {
|
||||
return this.state === SessionState["Inactive"]
|
||||
}
|
||||
activate() {
|
||||
this.state = SessionState["Active"]
|
||||
}
|
||||
deactivate() {
|
||||
this.state = SessionState["Inactive"]
|
||||
}
|
||||
name() {
|
||||
return `session - ${this.id}`
|
||||
}
|
||||
async startSession() {
|
||||
this.id += 1 //increment the session id for each session we start
|
||||
this.activate()
|
||||
this.isFirstGeneration = true // only before the first generation is requested should this be true
|
||||
|
||||
console.log("current session id: ", this.id)
|
||||
try {
|
||||
const session_name = this.name()
|
||||
const activeLayers = await app.activeDocument.activeLayers
|
||||
await psapi.unselectActiveLayersExe() // unselect all layer so the create group is place at the top of the document
|
||||
this.prevOutputGroup = this.outputGroup
|
||||
const outputGroup = await psapi.createEmptyGroup(session_name)
|
||||
this.outputGroup = outputGroup
|
||||
await psapi.selectLayersExe(activeLayers)
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
constructor() {
|
||||
//this should be unique session id and it also should act as the total number of sessions been created in the project
|
||||
this.id = 0
|
||||
this.state = SessionState['Inactive']
|
||||
this.mode = 'txt2img'
|
||||
this.selectionInfo = null
|
||||
this.isFirstGeneration = true // only before the first generation is requested should this be true
|
||||
this.outputGroup
|
||||
this.prevOutputGroup
|
||||
this.isLoadingActive = false
|
||||
}
|
||||
}
|
||||
async endSession(garbage_collection_state) {
|
||||
try {
|
||||
this.state = SessionState["Inactive"] // end the session by deactivate it
|
||||
|
||||
this.deactivate()
|
||||
|
||||
if (garbage_collection_state === GarbageCollectionState["Accept"]) {
|
||||
await acceptAll()
|
||||
} else if (
|
||||
garbage_collection_state === GarbageCollectionState["Discard"]
|
||||
) {
|
||||
//this should be discardAll()
|
||||
|
||||
await discardAll()
|
||||
} else if (
|
||||
garbage_collection_state === GarbageCollectionState["DiscardSelected"]
|
||||
) {
|
||||
//this should be discardAllExcept(selectedLayers)
|
||||
await discardSelected() //this will discard what is not been highlighted
|
||||
} else if (
|
||||
garbage_collection_state === GarbageCollectionState["AcceptSelected"]
|
||||
) {
|
||||
//this should be discardAllExcept(selectedLayers)
|
||||
await discard() //this will discard what is not been highlighted
|
||||
}
|
||||
|
||||
//delete the old selection area
|
||||
// g_selection = {}
|
||||
|
||||
this.isFirstGeneration = true // only before the first generation is requested should this be true
|
||||
// const is_visible = await this.outputGroup.visible
|
||||
await util_layer.collapseFolderExe([this.outputGroup], false) // close the folder group
|
||||
// this.outputGroup.visible = is_visible
|
||||
|
||||
if (
|
||||
this.mode === generationMode["Inpaint"] &&
|
||||
g_sd_mode === generationMode["Inpaint"]
|
||||
) {
|
||||
//create "Mask -- Paint White to Mask -- temporary" layer if current session was inpiant and the selected session is inpaint
|
||||
// the current inpaint session ended on inpaint
|
||||
g_b_mask_layer_exist = false
|
||||
await util_layer.deleteLayers([g_inpaint_mask_layer])
|
||||
await createTempInpaintMaskLayer()
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
isActive() {
|
||||
return this.state === SessionState['Active']
|
||||
}
|
||||
}
|
||||
async closePreviousOutputGroup() {
|
||||
try {
|
||||
//close the previous output folder
|
||||
isInactive() {
|
||||
return this.state === SessionState['Inactive']
|
||||
}
|
||||
activate() {
|
||||
this.state = SessionState['Active']
|
||||
}
|
||||
deactivate() {
|
||||
this.state = SessionState['Inactive']
|
||||
}
|
||||
name() {
|
||||
return `session - ${this.id}`
|
||||
}
|
||||
async startSession() {
|
||||
this.id += 1 //increment the session id for each session we start
|
||||
this.activate()
|
||||
this.isFirstGeneration = true // only before the first generation is requested should this be true
|
||||
|
||||
if (this.prevOutputGroup) {
|
||||
// const is_visible = await this.prevOutputGroup.visible
|
||||
await util_layer.collapseFolderExe([this.prevOutputGroup], false) // close the folder group
|
||||
// and reselect the current output folder for clarity
|
||||
await psapi.selectLayersExe([this.outputGroup])
|
||||
// this.prevOutputGroup.visible = is_visible
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
console.log('current session id: ', this.id)
|
||||
try {
|
||||
const session_name = this.name()
|
||||
const activeLayers = await app.activeDocument.activeLayers
|
||||
await psapi.unselectActiveLayersExe() // unselect all layer so the create group is place at the top of the document
|
||||
this.prevOutputGroup = this.outputGroup
|
||||
const outputGroup = await psapi.createEmptyGroup(session_name)
|
||||
this.outputGroup = outputGroup
|
||||
await psapi.selectLayersExe(activeLayers)
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
isSameMode(selected_mode) {
|
||||
if (this.mode === selected_mode) {
|
||||
return true
|
||||
async endSession(garbage_collection_state) {
|
||||
try {
|
||||
this.state = SessionState['Inactive'] // end the session by deactivate it
|
||||
|
||||
this.deactivate()
|
||||
|
||||
if (garbage_collection_state === GarbageCollectionState['Accept']) {
|
||||
await acceptAll()
|
||||
} else if (
|
||||
garbage_collection_state === GarbageCollectionState['Discard']
|
||||
) {
|
||||
//this should be discardAll()
|
||||
|
||||
await discardAll()
|
||||
} else if (
|
||||
garbage_collection_state ===
|
||||
GarbageCollectionState['DiscardSelected']
|
||||
) {
|
||||
//this should be discardAllExcept(selectedLayers)
|
||||
await discardSelected() //this will discard what is not been highlighted
|
||||
} else if (
|
||||
garbage_collection_state ===
|
||||
GarbageCollectionState['AcceptSelected']
|
||||
) {
|
||||
//this should be discardAllExcept(selectedLayers)
|
||||
await discard() //this will discard what is not been highlighted
|
||||
}
|
||||
|
||||
//delete the old selection area
|
||||
// g_selection = {}
|
||||
|
||||
this.isFirstGeneration = true // only before the first generation is requested should this be true
|
||||
// const is_visible = await this.outputGroup.visible
|
||||
await util_layer.collapseFolderExe([this.outputGroup], false) // close the folder group
|
||||
// this.outputGroup.visible = is_visible
|
||||
|
||||
if (
|
||||
this.mode === generationMode['Inpaint'] &&
|
||||
g_sd_mode === generationMode['Inpaint']
|
||||
) {
|
||||
//create "Mask -- Paint White to Mask -- temporary" layer if current session was inpiant and the selected session is inpaint
|
||||
// the current inpaint session ended on inpaint
|
||||
g_b_mask_layer_exist = false
|
||||
await util_layer.deleteLayers([g_inpaint_mask_layer])
|
||||
await createTempInpaintMaskLayer()
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
}
|
||||
async closePreviousOutputGroup() {
|
||||
try {
|
||||
//close the previous output folder
|
||||
|
||||
if (this.prevOutputGroup) {
|
||||
// const is_visible = await this.prevOutputGroup.visible
|
||||
await util_layer.collapseFolderExe(
|
||||
[this.prevOutputGroup],
|
||||
false
|
||||
) // close the folder group
|
||||
// and reselect the current output folder for clarity
|
||||
await psapi.selectLayersExe([this.outputGroup])
|
||||
// this.prevOutputGroup.visible = is_visible
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
}
|
||||
isSameMode(selected_mode) {
|
||||
if (this.mode === selected_mode) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
loadLastSession() {
|
||||
//load the last session from the server
|
||||
}
|
||||
saveCurrentSession() {
|
||||
//all session info will be saved in a json file in the project folder
|
||||
}
|
||||
async moveToTopOfOutputGroup(layer) {
|
||||
const output_group_id = await this.outputGroup.id
|
||||
let group_index = await psapi.getLayerIndex(output_group_id)
|
||||
const indexOffset = 1 //1 for background, 0 if no background exist
|
||||
await executeAsModal(async () => {
|
||||
await psapi.moveToGroupCommand(group_index - indexOffset, layer.id)
|
||||
})
|
||||
}
|
||||
return false
|
||||
}
|
||||
loadLastSession() {
|
||||
//load the last session from the server
|
||||
}
|
||||
saveCurrentSession() {
|
||||
//all session info will be saved in a json file in the project folder
|
||||
}
|
||||
async moveToTopOfOutputGroup(layer) {
|
||||
const output_group_id = await this.outputGroup.id
|
||||
let group_index = await psapi.getLayerIndex(output_group_id)
|
||||
const indexOffset = 1 //1 for background, 0 if no background exist
|
||||
await executeAsModal(async () => {
|
||||
await psapi.moveToGroupCommand(group_index - indexOffset, layer.id)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
GenerationSession,
|
||||
GarbageCollectionState,
|
||||
SessionState,
|
||||
GenerationSession,
|
||||
GarbageCollectionState,
|
||||
SessionState,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,40 +1,40 @@
|
|||
//tips that will display when you hover over a html element
|
||||
const tips_json = {
|
||||
snapshot: "",
|
||||
txt2img: "use this mode to generate images from text only",
|
||||
img2img: "use this mode to generate variation of an image",
|
||||
inpaint:
|
||||
"use this mode to generate variation of a small area of an image, while keeping the rest of the image intact",
|
||||
outpaint:
|
||||
"use this mode to (1) fill any missing area of an image,(2) expand an image",
|
||||
generate: "create",
|
||||
discardAll: "Delete all generated images from the canvas",
|
||||
acceptAll: "Keep all generated images on the canvas",
|
||||
acceptSelected: "Keep only the highlighted images",
|
||||
discardSelected: "Delete only the highlighted images",
|
||||
modelMenu: "select a model",
|
||||
refresh: "Refresh the plugin, only fixes minor issues.",
|
||||
prompt_shortcut: "use {keyword} form the prompts library",
|
||||
inpaint: "use when you need to modify an already existing part of an image",
|
||||
img2img: "use this mode when you want to generate variation of an image",
|
||||
txt2img: "use this mode to generate images based on text only",
|
||||
batchNumber:
|
||||
"the number of images to generate at once.The larger the number more VRAM stable diffusion will use.",
|
||||
steps: "how long should stable diffusion take to generate an image",
|
||||
selection_mode_ratio:
|
||||
"will auto fill the width and height slider to the same ratio as the selection area",
|
||||
selection_mode_precise:
|
||||
"auto fill width and height slider to the size as the selection area",
|
||||
selection_mode_ignore:
|
||||
"you will have to fill the width and height slider manually",
|
||||
cfg_scale: "larger value will put more emphasis on the prompt",
|
||||
preset_menu:
|
||||
"auto fill the plugin with smart settings, to speed up your working process.",
|
||||
width: "the generated image width",
|
||||
height: "the generated image height",
|
||||
mask_expansion:
|
||||
"the larger the value the more the mask will expand, '0' means use precise masking, use in combination with the mask blur",
|
||||
mask_content_fill: "",
|
||||
snapshot: '',
|
||||
txt2img: 'use this mode to generate images from text only',
|
||||
img2img: 'use this mode to generate variation of an image',
|
||||
inpaint:
|
||||
'use this mode to generate variation of a small area of an image, while keeping the rest of the image intact',
|
||||
outpaint:
|
||||
'use this mode to (1) fill any missing area of an image,(2) expand an image',
|
||||
generate: 'create',
|
||||
discardAll: 'Delete all generated images from the canvas',
|
||||
acceptAll: 'Keep all generated images on the canvas',
|
||||
acceptSelected: 'Keep only the highlighted images',
|
||||
discardSelected: 'Delete only the highlighted images',
|
||||
modelMenu: 'select a model',
|
||||
refresh: 'Refresh the plugin, only fixes minor issues.',
|
||||
prompt_shortcut: 'use {keyword} form the prompts library',
|
||||
inpaint: 'use when you need to modify an already existing part of an image',
|
||||
img2img: 'use this mode when you want to generate variation of an image',
|
||||
txt2img: 'use this mode to generate images based on text only',
|
||||
batchNumber:
|
||||
'the number of images to generate at once.The larger the number more VRAM stable diffusion will use.',
|
||||
steps: 'how long should stable diffusion take to generate an image',
|
||||
selection_mode_ratio:
|
||||
'will auto fill the width and height slider to the same ratio as the selection area',
|
||||
selection_mode_precise:
|
||||
'auto fill width and height slider to the size as the selection area',
|
||||
selection_mode_ignore:
|
||||
'you will have to fill the width and height slider manually',
|
||||
cfg_scale: 'larger value will put more emphasis on the prompt',
|
||||
preset_menu:
|
||||
'auto fill the plugin with smart settings, to speed up your working process.',
|
||||
width: 'the generated image width',
|
||||
height: 'the generated image height',
|
||||
mask_expansion:
|
||||
"the larger the value the more the mask will expand, '0' means use precise masking, use in combination with the mask blur",
|
||||
mask_content_fill: '',
|
||||
}
|
||||
|
||||
module.exports = { tips_json }
|
||||
|
|
|
|||
367
utility/ui.js
367
utility/ui.js
|
|
@ -1,102 +1,104 @@
|
|||
const { loadHistory } = require("../sdapi")
|
||||
const html_manip = require("./html_manip")
|
||||
const presets = require("./presets/preset")
|
||||
const { loadHistory } = require('../sdapi')
|
||||
const html_manip = require('./html_manip')
|
||||
const presets = require('./presets/preset')
|
||||
class UI {
|
||||
constructor() {}
|
||||
constructor() {}
|
||||
|
||||
onStartSessionUI() {
|
||||
// will toggle the buttons needed when a generation session start
|
||||
onStartSessionUI() {
|
||||
// will toggle the buttons needed when a generation session start
|
||||
|
||||
const accept_class_btns = Array.from(
|
||||
document.getElementsByClassName("acceptClass")
|
||||
)
|
||||
const accept_class_btns = Array.from(
|
||||
document.getElementsByClassName('acceptClass')
|
||||
)
|
||||
|
||||
const discard_class_btns = Array.from(
|
||||
document.getElementsByClassName("discardClass")
|
||||
)
|
||||
const discard_class_btns = Array.from(
|
||||
document.getElementsByClassName('discardClass')
|
||||
)
|
||||
|
||||
const discard_selected_class_btns = Array.from(
|
||||
document.getElementsByClassName("discardSelectedClass")
|
||||
)
|
||||
const discard_selected_class_btns = Array.from(
|
||||
document.getElementsByClassName('discardSelectedClass')
|
||||
)
|
||||
|
||||
const accept_selected_class_btns = Array.from(
|
||||
document.getElementsByClassName("acceptSelectedClass")
|
||||
)
|
||||
const accept_selected_class_btns = Array.from(
|
||||
document.getElementsByClassName('acceptSelectedClass')
|
||||
)
|
||||
|
||||
//show the accept and discard buttons when a new session is active
|
||||
accept_class_btns.forEach(
|
||||
(element) => (element.style.display = "inline-block")
|
||||
)
|
||||
discard_class_btns.forEach(
|
||||
(element) => (element.style.display = "inline-block")
|
||||
)
|
||||
discard_selected_class_btns.forEach(
|
||||
(element) => (element.style.display = "inline-block")
|
||||
)
|
||||
accept_selected_class_btns.forEach(
|
||||
(element) => (element.style.display = "inline-block")
|
||||
)
|
||||
//show the accept and discard buttons when a new session is active
|
||||
accept_class_btns.forEach(
|
||||
(element) => (element.style.display = 'inline-block')
|
||||
)
|
||||
discard_class_btns.forEach(
|
||||
(element) => (element.style.display = 'inline-block')
|
||||
)
|
||||
discard_selected_class_btns.forEach(
|
||||
(element) => (element.style.display = 'inline-block')
|
||||
)
|
||||
accept_selected_class_btns.forEach(
|
||||
(element) => (element.style.display = 'inline-block')
|
||||
)
|
||||
|
||||
this.generateMoreUI()
|
||||
}
|
||||
onActiveSessionUI() {}
|
||||
generateModeUI(mode) {
|
||||
const generate_btns = Array.from(
|
||||
document.getElementsByClassName("btnGenerateClass")
|
||||
)
|
||||
generate_btns.forEach((element) => {
|
||||
element.textContent = `Generate ${mode}`
|
||||
})
|
||||
html_manip.setGenerateButtonsColor("generate", "generate-more")
|
||||
}
|
||||
generateMoreUI() {
|
||||
const generate_btns = Array.from(
|
||||
document.getElementsByClassName("btnGenerateClass")
|
||||
)
|
||||
generate_btns.forEach((element) => {
|
||||
element.textContent = `Generate More`
|
||||
})
|
||||
html_manip.setGenerateButtonsColor("generate-more", "generate")
|
||||
}
|
||||
this.generateMoreUI()
|
||||
}
|
||||
onActiveSessionUI() {}
|
||||
generateModeUI(mode) {
|
||||
const generate_btns = Array.from(
|
||||
document.getElementsByClassName('btnGenerateClass')
|
||||
)
|
||||
generate_btns.forEach((element) => {
|
||||
element.textContent = `Generate ${mode}`
|
||||
})
|
||||
html_manip.setGenerateButtonsColor('generate', 'generate-more')
|
||||
}
|
||||
generateMoreUI() {
|
||||
const generate_btns = Array.from(
|
||||
document.getElementsByClassName('btnGenerateClass')
|
||||
)
|
||||
generate_btns.forEach((element) => {
|
||||
element.textContent = `Generate More`
|
||||
})
|
||||
html_manip.setGenerateButtonsColor('generate-more', 'generate')
|
||||
}
|
||||
|
||||
onEndSessionUI() {
|
||||
const accept_class_btns = Array.from(
|
||||
document.getElementsByClassName("acceptClass")
|
||||
)
|
||||
onEndSessionUI() {
|
||||
const accept_class_btns = Array.from(
|
||||
document.getElementsByClassName('acceptClass')
|
||||
)
|
||||
|
||||
const discard_class_btns = Array.from(
|
||||
document.getElementsByClassName("discardClass")
|
||||
)
|
||||
const discard_selected_class_btns = Array.from(
|
||||
document.getElementsByClassName("discardSelectedClass")
|
||||
)
|
||||
const discard_class_btns = Array.from(
|
||||
document.getElementsByClassName('discardClass')
|
||||
)
|
||||
const discard_selected_class_btns = Array.from(
|
||||
document.getElementsByClassName('discardSelectedClass')
|
||||
)
|
||||
|
||||
const accept_selected_class_btns = Array.from(
|
||||
//Node: change customClass to acceptSelectedClass
|
||||
document.getElementsByClassName("acceptSelectedClass")
|
||||
)
|
||||
const accept_selected_class_btns = Array.from(
|
||||
//Node: change customClass to acceptSelectedClass
|
||||
document.getElementsByClassName('acceptSelectedClass')
|
||||
)
|
||||
|
||||
accept_class_btns.forEach((element) => (element.style.display = "none"))
|
||||
discard_class_btns.forEach((element) => (element.style.display = "none"))
|
||||
discard_selected_class_btns.forEach(
|
||||
(element) => (element.style.display = "none")
|
||||
)
|
||||
accept_class_btns.forEach((element) => (element.style.display = 'none'))
|
||||
discard_class_btns.forEach(
|
||||
(element) => (element.style.display = 'none')
|
||||
)
|
||||
discard_selected_class_btns.forEach(
|
||||
(element) => (element.style.display = 'none')
|
||||
)
|
||||
|
||||
accept_selected_class_btns.forEach(
|
||||
(element) => (element.style.display = "none")
|
||||
)
|
||||
accept_selected_class_btns.forEach(
|
||||
(element) => (element.style.display = 'none')
|
||||
)
|
||||
|
||||
this.generateModeUI(g_sd_mode)
|
||||
}
|
||||
this.generateModeUI(g_sd_mode)
|
||||
}
|
||||
|
||||
setGenerateBtnText(textContent) {
|
||||
const generate_btns = Array.from(
|
||||
document.getElementsByClassName("btnGenerateClass")
|
||||
)
|
||||
generate_btns.forEach((element) => {
|
||||
element.textContent = textContent
|
||||
})
|
||||
}
|
||||
setGenerateBtnText(textContent) {
|
||||
const generate_btns = Array.from(
|
||||
document.getElementsByClassName('btnGenerateClass')
|
||||
)
|
||||
generate_btns.forEach((element) => {
|
||||
element.textContent = textContent
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// const defaultSettings = {
|
||||
|
|
@ -124,126 +126,131 @@ class UI {
|
|||
// }
|
||||
|
||||
class UIElement {
|
||||
constructor() {
|
||||
this.name
|
||||
this.html_elem
|
||||
this.sd_value
|
||||
}
|
||||
setValue() {}
|
||||
getValue() {}
|
||||
constructor() {
|
||||
this.name
|
||||
this.html_elem
|
||||
this.sd_value
|
||||
}
|
||||
setValue() {}
|
||||
getValue() {}
|
||||
}
|
||||
function createUIElement(getter, setter) {
|
||||
let ui_element_obj = new ui.UIElement()
|
||||
ui_element_obj.getValue = getter
|
||||
ui_element_obj.setValue = setter
|
||||
return ui_element_obj
|
||||
let ui_element_obj = new ui.UIElement()
|
||||
ui_element_obj.getValue = getter
|
||||
ui_element_obj.setValue = setter
|
||||
return ui_element_obj
|
||||
}
|
||||
class UISettings {
|
||||
// get and set the settings of the ui. the stable diffusion settings not the human friendly settings
|
||||
constructor() {
|
||||
// this.width = new ui.UIElement()
|
||||
// this.width.getValue = html_manip.getWidth
|
||||
// this.width.setValue = html_manip.autoFillInWidth
|
||||
this.width = createUIElement(
|
||||
html_manip.getWidth,
|
||||
html_manip.autoFillInWidth
|
||||
)
|
||||
this.height = createUIElement(
|
||||
html_manip.getHeight,
|
||||
html_manip.autoFillInHeight
|
||||
)
|
||||
this.steps = createUIElement(
|
||||
html_manip.getSteps,
|
||||
html_manip.autoFillInSteps
|
||||
)
|
||||
this.batch_number = createUIElement(
|
||||
html_manip.getBatchNumber,
|
||||
html_manip.autoFillInBatchNumber
|
||||
)
|
||||
this.firstphase_width = createUIElement(
|
||||
html_manip.getHrWidth,
|
||||
html_manip.autoFillInHRWidth
|
||||
)
|
||||
this.firstphase_height = createUIElement(
|
||||
html_manip.getHrHeight,
|
||||
html_manip.autoFillInHRHeight
|
||||
)
|
||||
this.cfg = createUIElement(html_manip.getCFG, html_manip.setCFG)
|
||||
this.denoising_strength = createUIElement(
|
||||
html_manip.getDenoisingStrength,
|
||||
html_manip.autoFillInDenoisingStrength
|
||||
)
|
||||
// get and set the settings of the ui. the stable diffusion settings not the human friendly settings
|
||||
constructor() {
|
||||
// this.width = new ui.UIElement()
|
||||
// this.width.getValue = html_manip.getWidth
|
||||
// this.width.setValue = html_manip.autoFillInWidth
|
||||
this.width = createUIElement(
|
||||
html_manip.getWidth,
|
||||
html_manip.autoFillInWidth
|
||||
)
|
||||
this.height = createUIElement(
|
||||
html_manip.getHeight,
|
||||
html_manip.autoFillInHeight
|
||||
)
|
||||
this.steps = createUIElement(
|
||||
html_manip.getSteps,
|
||||
html_manip.autoFillInSteps
|
||||
)
|
||||
this.batch_number = createUIElement(
|
||||
html_manip.getBatchNumber,
|
||||
html_manip.autoFillInBatchNumber
|
||||
)
|
||||
this.firstphase_width = createUIElement(
|
||||
html_manip.getHrWidth,
|
||||
html_manip.autoFillInHRWidth
|
||||
)
|
||||
this.firstphase_height = createUIElement(
|
||||
html_manip.getHrHeight,
|
||||
html_manip.autoFillInHRHeight
|
||||
)
|
||||
this.cfg = createUIElement(html_manip.getCFG, html_manip.setCFG)
|
||||
this.denoising_strength = createUIElement(
|
||||
html_manip.getDenoisingStrength,
|
||||
html_manip.autoFillInDenoisingStrength
|
||||
)
|
||||
|
||||
this.mask_content = createUIElement(
|
||||
html_manip.getMaskContent,
|
||||
html_manip.setMaskContent
|
||||
)
|
||||
this.uiElements = {
|
||||
// model: null,
|
||||
// prompt_shortcut: null,
|
||||
// positive_prompt: "",
|
||||
// negative_prompt: "",
|
||||
// selection_mode: null,
|
||||
batch_number: this.batch_number,
|
||||
steps: this.steps,
|
||||
width: this.width,
|
||||
height: this.height,
|
||||
firstphase_width: this.firstphase_width,
|
||||
firstphase_height: this.firstphase_height,
|
||||
cfg: this.cfg,
|
||||
denoising_strength: this.denoising_strength,
|
||||
// hi_res_denoising_strength:0.7,
|
||||
// mask_blur: 8,
|
||||
// inpaint_at_full_res: false,
|
||||
// hi_res_fix:false,
|
||||
// inpaint_padding:0,
|
||||
// seed:-1,
|
||||
// samplers: null,
|
||||
mask_content: this.mask_content,
|
||||
this.mask_content = createUIElement(
|
||||
html_manip.getMaskContent,
|
||||
html_manip.setMaskContent
|
||||
)
|
||||
this.uiElements = {
|
||||
// model: null,
|
||||
// prompt_shortcut: null,
|
||||
// positive_prompt: "",
|
||||
// negative_prompt: "",
|
||||
// selection_mode: null,
|
||||
batch_number: this.batch_number,
|
||||
steps: this.steps,
|
||||
width: this.width,
|
||||
height: this.height,
|
||||
firstphase_width: this.firstphase_width,
|
||||
firstphase_height: this.firstphase_height,
|
||||
cfg: this.cfg,
|
||||
denoising_strength: this.denoising_strength,
|
||||
// hi_res_denoising_strength:0.7,
|
||||
// mask_blur: 8,
|
||||
// inpaint_at_full_res: false,
|
||||
// hi_res_fix:false,
|
||||
// inpaint_padding:0,
|
||||
// seed:-1,
|
||||
// samplers: null,
|
||||
mask_content: this.mask_content,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
autoFillInSettings(settings) {
|
||||
for (const [name, value] of Object.entries(settings)) {
|
||||
if (this.uiElements.hasOwnProperty(name) && value) {
|
||||
//get the values for debugging
|
||||
const old_value = this.uiElements[name].getValue()
|
||||
console.log("(name,old_value) => newValue:", name, old_value, value)
|
||||
//set the value
|
||||
this.uiElements[name].setValue(value)
|
||||
}
|
||||
autoFillInSettings(settings) {
|
||||
for (const [name, value] of Object.entries(settings)) {
|
||||
if (this.uiElements.hasOwnProperty(name) && value) {
|
||||
//get the values for debugging
|
||||
const old_value = this.uiElements[name].getValue()
|
||||
console.log(
|
||||
'(name,old_value) => newValue:',
|
||||
name,
|
||||
old_value,
|
||||
value
|
||||
)
|
||||
//set the value
|
||||
this.uiElements[name].setValue(value)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// const ui_settings = new UISettings()
|
||||
|
||||
function loadPreset(ui_settings, preset) {
|
||||
console.log("preset:", preset)
|
||||
ui_settings.autoFillInSettings(preset)
|
||||
console.log('preset:', preset)
|
||||
ui_settings.autoFillInSettings(preset)
|
||||
}
|
||||
|
||||
function loadLatentNoiseSettings(ui_settings) {
|
||||
loadPreset(ui_settings, presets.LatentNoiseSettings)
|
||||
loadPreset(ui_settings, presets.LatentNoiseSettings)
|
||||
}
|
||||
|
||||
function loadFillSettings(ui_settings) {
|
||||
loadPreset(ui_settings, presets.FillSettings)
|
||||
loadPreset(ui_settings, presets.FillSettings)
|
||||
}
|
||||
function loadOriginalSettings(ui_settings) {
|
||||
loadPreset(ui_settings, presets.OriginalSettings)
|
||||
loadPreset(ui_settings, presets.OriginalSettings)
|
||||
}
|
||||
let loadedPresets = {
|
||||
fill: loadFillSettings,
|
||||
original: loadOriginalSettings,
|
||||
"latent noise": loadLatentNoiseSettings,
|
||||
fill: loadFillSettings,
|
||||
original: loadOriginalSettings,
|
||||
'latent noise': loadLatentNoiseSettings,
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
UI,
|
||||
UIElement,
|
||||
UISettings,
|
||||
loadLatentNoiseSettings,
|
||||
loadFillSettings,
|
||||
UI,
|
||||
UIElement,
|
||||
UISettings,
|
||||
loadLatentNoiseSettings,
|
||||
loadFillSettings,
|
||||
|
||||
loadedPresets,
|
||||
loadedPresets,
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue