Skip to content

Commit

Permalink
Merge pull request #378 from AbdullahAlfaraj/1.3.3
Browse files Browse the repository at this point in the history
v1.3.3
  • Loading branch information
AbdullahAlfaraj authored Oct 7, 2023
2 parents ad4fcfa + eebb3cb commit 0fcfff2
Show file tree
Hide file tree
Showing 47 changed files with 1,121 additions and 812 deletions.
5 changes: 3 additions & 2 deletions build-script/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ module.exports = {
},
mode: 'development',
// mode: 'production',
devtool: 'inline-source-map', // won't work on XD due to lack of eval
// devtool: 'source-map',

devtool: false,

externals: {
uxp: 'commonjs2 uxp',
photoshop: 'commonjs2 photoshop',
Expand Down
5 changes: 5 additions & 0 deletions icon/search_button.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 5 additions & 60 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,8 @@
}

#rbSelectionModeLabel,
.rbSelectionMode {
.rbSelectionMode,
.rbBaseSize {
font-size: 1em;
margin-right: 12px;
}
Expand Down Expand Up @@ -740,9 +741,6 @@
<sp-label>ControlNet</sp-label>
</div>

<div class="sp-tab" id="sp-lexica-tab" style="display: none">
<sp-label>Lexica</sp-label>
</div>
<div
class="sp-tab"
id="sp-image_search-tab"
Expand Down Expand Up @@ -853,14 +851,6 @@
value="prompts-library"
>Prompts Library</sp-radio
>
<sp-radio
title=""
class="rbSubTab"
id="rbLexica"
data-tab-name="sp-lexica-tab"
value="lexica"
>Lexica</sp-radio
>
</sp-radio-group>
</div>
<div id="viewerSubTab">
Expand Down Expand Up @@ -896,48 +886,6 @@
</div>
<div class="sp-tab-page" id="sp-control_net-tab-page"></div>

<div class="sp-tab-page" id="sp-lexica-tab-page">
<div class="subTabOptionsContainer"></div>

<div class="flexContainer">
<sp-label slot="label"
>Explore Lexica for prompts and inspiration</sp-label
>
</div>
<div></div>
<div>
<sp-textfield
id="LexicaSearchField"
type="text"
placeholder="cute cats"
value=""
><sp-label slot="label">Search:</sp-label></sp-textfield
>

<button
class="btnSquare search-button"
id="btnSearchLexica"
title="user prompt(text) to Search Lexica"
></button>

<button
class="btnSquare reverse_image_serach"
id="btnReverseSearchLexica"
title="User the selected area (image) on canvas to Search Lexica"
></button>
</div>
<sp-textarea id="lexicaPrompt" style="margin-bottom: 3px">
</sp-textarea>
<div class="viewer-container" id="divLexicaImagesContainer">
<img
class="history-image"
id="history_image_test"
data-metadata_json_string='{"a":1}'
src="https://source.unsplash.com/random"
/>
</div>
</div>

<div class="sp-tab-page" id="sp-image_search-tab-page">
<div class="subTabOptionsContainer"></div>

Expand Down Expand Up @@ -1128,12 +1076,6 @@
<div id="settingsVAEContainer"></div>
<div id="reactSettingsContainer"></div>

<div>
<sp-checkbox checked id="chUseSmartObject"
>Smart Object</sp-checkbox
>
</div>

<div>
<sp-checkbox checked id="chUseOriginalPrompt"
>Restore Original Prompt</sp-checkbox
Expand Down Expand Up @@ -1237,6 +1179,9 @@
<div id="historyImagesContainer"></div>
<sp-divider class="line-divider" size="large"></sp-divider>
<sp-divider class="line-divider" size="large"></sp-divider>
<div class="lexicaContainer"></div>
<sp-divider class="line-divider" size="large"></sp-divider>
<sp-divider class="line-divider" size="large"></sp-divider>
</div>
</uxp-panel>

Expand Down
67 changes: 18 additions & 49 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const settings_tab = require('./utility/tab/settings')
//load tabs

const image_search_tab = require('./utility/tab/image_search_tab')
const lexica_tab = require('./utility/tab/lexica_tab')

// const share_tab = require('./utility/tab/share_tab')
const api = require('./utility/api')

Expand Down Expand Up @@ -88,6 +88,8 @@ const {
extra_page,
selection_ts,
stores,
lexica,
api_ts,
} = require('./typescripts/dist/bundle')

const io = require('./utility/io')
Expand Down Expand Up @@ -191,20 +193,24 @@ async function hasSessionSelectionChanged() {
}
}

async function calcWidthHeightFromSelection() {
async function calcWidthHeightFromSelection(selectionInfo) {
//set the width and height, hrWidth, and hrHeight using selection info and selection mode
const selection_mode = sd_tab_store.data.selection_mode
if (selection_mode === 'ratio') {
//change (width and height) and (hrWidth, hrHeight) to match the ratio of selection
const base_size = sd_tab_util.helper_store.data.base_size
const [width, height, hr_width, hr_height] =
await selection.selectionToFinalWidthHeight()
await selection.selectionToFinalWidthHeight(
selectionInfo,
base_size,
base_size
)
// console.log('width,height: ', width, height)
html_manip.autoFillInWidth(width)
html_manip.autoFillInHeight(height)
html_manip.autoFillInHRWidth(hr_width)
html_manip.autoFillInHRHeight(hr_height)
} else if (selection_mode === 'precise') {
const selectionInfo = await psapi.getSelectionInfoExe()
const [width, height, hr_width, hr_height] = [
selectionInfo.width,
selectionInfo.height,
Expand All @@ -227,9 +233,7 @@ const eventHandler = async (event, descriptor) => {

// const isSelectionActive = await psapi.checkIfSelectionAreaIsActive()
if (new_selection_info) {
const current_selection = new_selection_info // Note: don't use checkIfSelectionAreaIsActive to return the selection object, change this.

await calcWidthHeightFromSelection()
await calcWidthHeightFromSelection(new_selection_info)
}
} catch (e) {
console.warn(e)
Expand Down Expand Up @@ -665,7 +669,7 @@ document.addEventListener('mouseenter', async (event) => {
) {
// if there is an active selection and if the selection has changed

await calcWidthHeightFromSelection()
await calcWidthHeightFromSelection(new_selection)
} else {
// sessionStartHtml(true)//generate more, green color
//if you didn't move the selection.
Expand Down Expand Up @@ -1134,30 +1138,6 @@ async function convertToSmartObjectExe() {
await require('photoshop').core.executeAsModal(convertToSmartObjectAction)
}

async function ImagesToLayersExe(images_paths) {
g_generation_session.isLoadingActive = true

await psapi.reSelectMarqueeExe(g_generation_session.selectionInfo)
image_path_to_layer = {}
console.log('ImagesToLayersExe: images_paths: ', images_paths)
for (image_path of images_paths) {
gCurrentImagePath = image_path
console.log(gCurrentImagePath)
await openImageExe() //local image to new document
await convertToSmartObjectExe() //convert the current image to smart object
if (g_b_use_smart_object === false) {
await executeAsModal(async () => {
await app.activeDocument.activeLayers[0].rasterize() //rastrize the active layer
})
}
await stackLayers() // move the smart object to the original/old document
await psapi.layerToSelection(g_generation_session.selectionInfo) //transform the new smart object layer to fit selection area
layer = await app.activeDocument.activeLayers[0]
image_path_to_layer[image_path] = layer
// await reselect(selectionInfo)
}
return image_path_to_layer
}
//REFACTOR: unused, remove?
async function silentImagesToLayersExe_old(images_info) {
try {
Expand Down Expand Up @@ -1504,19 +1484,13 @@ document

//REFACTOR: move to document.js
async function loadPromptShortcut() {
try {
let prompt_shortcut = await sdapi.loadPromptShortcut()
if (!prompt_shortcut || prompt_shortcut === {}) {
prompt_shortcut = promptShortcutExample()
}

// var JSONInPrettyFormat = JSON.stringify(prompt_shortcut, undefined, 4);
// document.getElementById('taPromptShortcut').value = JSONInPrettyFormat
html_manip.setPromptShortcut(prompt_shortcut) // fill the prompt shortcut textarea
await refreshPromptMenu() //refresh the prompt menue
} catch (e) {
console.warn(`loadPromptShortcut warning: ${e}`)
let prompt_shortcut = await sdapi.loadPromptShortcut() // always return json object or empty object {}
if (!Object.keys(prompt_shortcut).length) {
//load the default prompt shortcut if we have an empty prompt shortcut object (on failure to load from file)
prompt_shortcut = promptShortcutExample()
}
html_manip.setPromptShortcut(prompt_shortcut) // fill the prompt shortcut textarea
await refreshPromptMenu() //refresh the prompt menu
}
//REFACTOR: move to ui.js
async function refreshPromptMenu() {
Expand Down Expand Up @@ -1704,11 +1678,6 @@ const submenu = {
'data-tab-name': 'sp-prompts-library-tab',
},

lexica: {
value: 'lexica',
Label: 'Lexica',
'data-tab-name': 'sp-lexica-tab',
},
image_search: {
value: 'image_search',
Label: 'Image Search',
Expand Down
2 changes: 1 addition & 1 deletion install.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
# print("Auto-Photoshop-SD plugin is installing")

package_name = 'duckduckgo_search'
package_version= '3.7.1'
package_version= '3.9.1'
if not launch.is_installed(package_name):
launch.run_pip(f"install {package_name}=={package_version}", "requirements for Auto-Photoshop Image Search")
else:# it's installed but we need to check for update
Expand Down
3 changes: 2 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"main": "index.html",
"manifestVersion": 5,
"requiredPermissions": {
"allowCodeGenerationFromStrings": true,
"network": {
"domains": "all"
},
Expand Down Expand Up @@ -43,7 +44,7 @@
},
"minimumSize": {
"width": 400,
"height": 800
"height": 400
},
"maximumSize": {
"width": 1200,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"watch": "npx webpack --config ./build-script/webpack.config.js --watch",
"watch": "npx webpack --config ./build-script/webpack.config.js --watch --devtool eval-source-map",
"build": "npx webpack --config ./build-script/webpack.config.js",
"publish": "npx webpack --config ./build-script/webpack.config.js --mode production",
"format": "npx prettier -w typescripts"
Expand Down
1 change: 0 additions & 1 deletion presets/default.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"sd_tab_preset": {
"selected_model": "v1-5-pruned-emaonly.ckpt [cc6cb27103]",
"is_lasso_mode": false,
"mode": "txt2img",
"rb_mode": "txt2img",
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ uvicorn==0.20.0
# uvloop==0.17.0
watchfiles==0.18.1
websockets==10.4
duckduckgo_search==3.7.1
duckduckgo_search==3.9.1
3 changes: 1 addition & 2 deletions sdapi_py_re.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ async function requestGetConfig() {
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)
Expand All @@ -194,7 +194,6 @@ async function requestGetOptions() {
}

json = await request.json()
console.log('models json:')
console.dir(json)
} catch (e) {
console.warn(`issues requesting from ${full_url}`, e)
Expand Down
Loading

0 comments on commit 0fcfff2

Please sign in to comment.