Merge branch 'main' into main

This commit is contained in:
Millun Atluri 2023-09-27 12:28:24 +10:00 committed by GitHub
commit 164877b610
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 16 deletions

View File

@ -3,9 +3,9 @@ import { canvasImageToControlNet } from 'features/canvas/store/actions';
import { getBaseLayerBlob } from 'features/canvas/util/getBaseLayerBlob'; import { getBaseLayerBlob } from 'features/canvas/util/getBaseLayerBlob';
import { controlNetImageChanged } from 'features/controlNet/store/controlNetSlice'; import { controlNetImageChanged } from 'features/controlNet/store/controlNetSlice';
import { addToast } from 'features/system/store/systemSlice'; import { addToast } from 'features/system/store/systemSlice';
import { t } from 'i18next';
import { imagesApi } from 'services/api/endpoints/images'; import { imagesApi } from 'services/api/endpoints/images';
import { startAppListening } from '..'; import { startAppListening } from '..';
import { t } from 'i18next';
export const addCanvasImageToControlNetListener = () => { export const addCanvasImageToControlNetListener = () => {
startAppListening({ startAppListening({
@ -16,7 +16,7 @@ export const addCanvasImageToControlNetListener = () => {
let blob; let blob;
try { try {
blob = await getBaseLayerBlob(state); blob = await getBaseLayerBlob(state, true);
} catch (err) { } catch (err) {
log.error(String(err)); log.error(String(err));
dispatch( dispatch(
@ -36,10 +36,10 @@ export const addCanvasImageToControlNetListener = () => {
file: new File([blob], 'savedCanvas.png', { file: new File([blob], 'savedCanvas.png', {
type: 'image/png', type: 'image/png',
}), }),
image_category: 'mask', image_category: 'control',
is_intermediate: false, is_intermediate: false,
board_id: autoAddBoardId === 'none' ? undefined : autoAddBoardId, board_id: autoAddBoardId === 'none' ? undefined : autoAddBoardId,
crop_visible: true, crop_visible: false,
postUploadAction: { postUploadAction: {
type: 'TOAST', type: 'TOAST',
toastOptions: { title: t('toast.canvasSentControlnetAssets') }, toastOptions: { title: t('toast.canvasSentControlnetAssets') },

View File

@ -3,9 +3,9 @@ import { canvasMaskToControlNet } from 'features/canvas/store/actions';
import { getCanvasData } from 'features/canvas/util/getCanvasData'; import { getCanvasData } from 'features/canvas/util/getCanvasData';
import { controlNetImageChanged } from 'features/controlNet/store/controlNetSlice'; import { controlNetImageChanged } from 'features/controlNet/store/controlNetSlice';
import { addToast } from 'features/system/store/systemSlice'; import { addToast } from 'features/system/store/systemSlice';
import { t } from 'i18next';
import { imagesApi } from 'services/api/endpoints/images'; import { imagesApi } from 'services/api/endpoints/images';
import { startAppListening } from '..'; import { startAppListening } from '..';
import { t } from 'i18next';
export const addCanvasMaskToControlNetListener = () => { export const addCanvasMaskToControlNetListener = () => {
startAppListening({ startAppListening({
@ -50,7 +50,7 @@ export const addCanvasMaskToControlNetListener = () => {
image_category: 'mask', image_category: 'mask',
is_intermediate: false, is_intermediate: false,
board_id: autoAddBoardId === 'none' ? undefined : autoAddBoardId, board_id: autoAddBoardId === 'none' ? undefined : autoAddBoardId,
crop_visible: true, crop_visible: false,
postUploadAction: { postUploadAction: {
type: 'TOAST', type: 'TOAST',
toastOptions: { title: t('toast.maskSentControlnetAssets') }, toastOptions: { title: t('toast.maskSentControlnetAssets') },

View File

@ -1,11 +1,14 @@
import { getCanvasBaseLayer } from './konvaInstanceProvider';
import { RootState } from 'app/store/store'; import { RootState } from 'app/store/store';
import { getCanvasBaseLayer } from './konvaInstanceProvider';
import { konvaNodeToBlob } from './konvaNodeToBlob'; import { konvaNodeToBlob } from './konvaNodeToBlob';
/** /**
* Get the canvas base layer blob, with or without bounding box according to `shouldCropToBoundingBoxOnSave` * Get the canvas base layer blob, with or without bounding box according to `shouldCropToBoundingBoxOnSave`
*/ */
export const getBaseLayerBlob = async (state: RootState) => { export const getBaseLayerBlob = async (
state: RootState,
alwaysUseBoundingBox: boolean = false
) => {
const canvasBaseLayer = getCanvasBaseLayer(); const canvasBaseLayer = getCanvasBaseLayer();
if (!canvasBaseLayer) { if (!canvasBaseLayer) {
@ -24,14 +27,15 @@ export const getBaseLayerBlob = async (state: RootState) => {
const absPos = clonedBaseLayer.getAbsolutePosition(); const absPos = clonedBaseLayer.getAbsolutePosition();
const boundingBox = shouldCropToBoundingBoxOnSave const boundingBox =
? { shouldCropToBoundingBoxOnSave || alwaysUseBoundingBox
x: boundingBoxCoordinates.x + absPos.x, ? {
y: boundingBoxCoordinates.y + absPos.y, x: boundingBoxCoordinates.x + absPos.x,
width: boundingBoxDimensions.width, y: boundingBoxCoordinates.y + absPos.y,
height: boundingBoxDimensions.height, width: boundingBoxDimensions.width,
} height: boundingBoxDimensions.height,
: clonedBaseLayer.getClientRect(); }
: clonedBaseLayer.getClientRect();
return konvaNodeToBlob(clonedBaseLayer, boundingBox); return konvaNodeToBlob(clonedBaseLayer, boundingBox);
}; };