use the silent method to export the mask and init image
parent
870b67a63c
commit
1aec59a1e3
36
index.js
36
index.js
|
|
@ -9,7 +9,7 @@ const helper = require('./helper')
|
|||
// const sdapi = require(`./${g_sdapi_path}`)
|
||||
const sdapi = require('./sdapi_py_re')
|
||||
|
||||
const exportHelper = require('./export_png')
|
||||
// const exportHelper = require('./export_png')
|
||||
const outpaint = require('./outpaint')
|
||||
const psapi = require('./psapi')
|
||||
const app = window.require('photoshop').app
|
||||
|
|
@ -34,6 +34,7 @@ const storage = require('uxp').storage
|
|||
const fs = storage.localFileSystem
|
||||
const horde_native = require('./utility/sdapi/horde_native')
|
||||
const io = require('./utility/io')
|
||||
const general = require('./utility/general')
|
||||
let g_horde_generator = new horde_native.hordeGenerator()
|
||||
|
||||
async function hasSessionSelectionChanged() {
|
||||
|
|
@ -2480,7 +2481,10 @@ document
|
|||
.addEventListener('click', async () => {
|
||||
//set init image event listener, use when settion is active
|
||||
const layer = await app.activeDocument.activeLayers[0]
|
||||
const image_info = await psapi.setInitImage(layer, random_session_id)
|
||||
const image_info = await psapi.silentSetInitImage(
|
||||
layer,
|
||||
random_session_id
|
||||
)
|
||||
const image_name = image_info['name']
|
||||
const path = `./server/python_server/init_images/${image_name}`
|
||||
g_viewer_manager.addInitImageLayers(layer, path, false)
|
||||
|
|
@ -2497,7 +2501,7 @@ document
|
|||
})
|
||||
const layer = g_viewer_manager.maskGroup
|
||||
// const layer = await app.activeDocument.activeLayers[0]
|
||||
const mask_info = await psapi.setInitImageMask(
|
||||
const mask_info = await psapi.silentSetInitImageMask(
|
||||
layer,
|
||||
random_session_id
|
||||
)
|
||||
|
|
@ -4086,29 +4090,3 @@ async function prmoptForUpdate() {
|
|||
document.getElementById('btnUpdate').addEventListener('click', async () => {
|
||||
await prmoptForUpdate()
|
||||
})
|
||||
|
||||
function urlToImg(img_url) {
|
||||
//TODO: delete this code
|
||||
var xhr = new XMLHttpRequest()
|
||||
|
||||
// Use JSFiddle logo as a sample image to avoid complicating
|
||||
// this example with cross-domain issues.
|
||||
// xhr.open('GET', 'http://fiddle.jshell.net/img/logo.png', true)
|
||||
|
||||
xhr.open('GET', img_url, true)
|
||||
|
||||
// Ask for the result as an ArrayBuffer.
|
||||
xhr.responseType = 'arraybuffer'
|
||||
|
||||
xhr.onload = function (e) {
|
||||
// Obtain a blob: URL for the image data.
|
||||
var arrayBufferView = new Uint8Array(this.response)
|
||||
var blob = new Blob([arrayBufferView], { type: 'image/png' })
|
||||
var urlCreator = window.URL || window.webkitURL
|
||||
var imageUrl = urlCreator.createObjectURL(blob)
|
||||
var img = document.getElementById('webp_container')
|
||||
img.src = imageUrl
|
||||
}
|
||||
|
||||
xhr.send()
|
||||
}
|
||||
|
|
|
|||
27
outpaint.js
27
outpaint.js
|
|
@ -186,7 +186,7 @@ async function snapAndFillExe(session_id) {
|
|||
// g_init_image_related_layers['init_image_layer'] = snapshotLayer
|
||||
// g_init_image_related_layers['solid_white'] = whiteSolidLayer
|
||||
|
||||
const image_info = await psapi.setInitImage(
|
||||
const image_info = await psapi.silentSetInitImage(
|
||||
snapshotGroup,
|
||||
session_id
|
||||
)
|
||||
|
|
@ -401,10 +401,18 @@ async function outpaintExe(session_id) {
|
|||
|
||||
await addClippingMaskToLayer(snapshotGroup, selectionInfo)
|
||||
|
||||
const image_info = await psapi.setInitImage(
|
||||
const mask_info = await psapi.silentSetInitImageMask(
|
||||
snapshotMaskGroup,
|
||||
session_id
|
||||
)
|
||||
snapshotMaskGroup.visible = false
|
||||
|
||||
const image_info = await psapi.silentSetInitImage(
|
||||
snapshotGroup,
|
||||
session_id
|
||||
)
|
||||
snapshotGroup.visible = false
|
||||
|
||||
const init_image_name = image_info['name']
|
||||
const init_path = `./server/python_server/init_images/${init_image_name}`
|
||||
|
||||
|
|
@ -414,11 +422,8 @@ async function outpaintExe(session_id) {
|
|||
|
||||
await psapi.reSelectMarqueeExe(selectionInfo)
|
||||
|
||||
// await psapi.setInitImageMask(snapshotMaskGroup,session_id)
|
||||
const mask_info = await psapi.setInitImageMask(
|
||||
snapshotMaskGroup,
|
||||
session_id
|
||||
)
|
||||
// await psapi.silentSetInitImageMask(snapshotMaskGroup,session_id)
|
||||
|
||||
const mask_name = mask_info['name']
|
||||
const mask_path = `./server/python_server/init_images/${mask_name}`
|
||||
await psapi.reSelectMarqueeExe(selectionInfo)
|
||||
|
|
@ -559,18 +564,20 @@ async function inpaintFasterExe(session_id) {
|
|||
// await psapi.selectLayers([snapshotGroup])
|
||||
|
||||
await psapi.selectLayers([maskGroup])
|
||||
// await psapi.setInitImageMask(maskGroup,session_id)
|
||||
const mask_info = await psapi.setInitImageMask(
|
||||
// await psapi.silentSetInitImageMask(maskGroup,session_id)
|
||||
const mask_info = await psapi.silentSetInitImageMask(
|
||||
maskGroup,
|
||||
session_id
|
||||
)
|
||||
//hide the mask so you can take screenshot of the init image
|
||||
maskGroup.visible = false
|
||||
const mask_name = mask_info['name']
|
||||
const mask_path = `./server/python_server/init_images/${mask_name}`
|
||||
|
||||
await psapi.reSelectMarqueeExe(selectionInfo)
|
||||
await psapi.selectLayers([snapshotGroup])
|
||||
|
||||
const image_info = await psapi.setInitImage(
|
||||
const image_info = await psapi.silentSetInitImage(
|
||||
snapshotGroup,
|
||||
session_id
|
||||
)
|
||||
|
|
|
|||
1
psapi.js
1
psapi.js
|
|
@ -1460,4 +1460,5 @@ module.exports = {
|
|||
snapshot_layer_no_slide_Exe,
|
||||
setVisibleExe,
|
||||
silentSetInitImage,
|
||||
silentSetInitImageMask,
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue