add Download mask settings
This commit is contained in:
parent
a94f7e4ffe
commit
1f8fb29594
@ -22,6 +22,7 @@ import Button from '../shared/Button'
|
|||||||
import Slider from './Slider'
|
import Slider from './Slider'
|
||||||
import SizeSelector from './SizeSelector'
|
import SizeSelector from './SizeSelector'
|
||||||
import {
|
import {
|
||||||
|
dataURItoBlob,
|
||||||
downloadImage,
|
downloadImage,
|
||||||
isMidClick,
|
isMidClick,
|
||||||
isRightClick,
|
isRightClick,
|
||||||
@ -648,6 +649,20 @@ export default function Editor(props: EditorProps) {
|
|||||||
const name = file.name.replace(/(\.[\w\d_-]+)$/i, '_cleanup$1')
|
const name = file.name.replace(/(\.[\w\d_-]+)$/i, '_cleanup$1')
|
||||||
const curRender = renders[renders.length - 1]
|
const curRender = renders[renders.length - 1]
|
||||||
downloadImage(curRender.currentSrc, name)
|
downloadImage(curRender.currentSrc, name)
|
||||||
|
if (settings.downloadMask) {
|
||||||
|
let maskFileName = file.name.replace(/(\.[\w\d_-]+)$/i, '_mask$1')
|
||||||
|
maskFileName = maskFileName.replace(/\.[^/.]+$/, '.jpg')
|
||||||
|
|
||||||
|
drawLinesOnMask(lineGroups)
|
||||||
|
// Create a link
|
||||||
|
const aDownloadLink = document.createElement('a')
|
||||||
|
// Add the name of the file to the link
|
||||||
|
aDownloadLink.download = maskFileName
|
||||||
|
// Attach the data to the link
|
||||||
|
aDownloadLink.href = maskCanvas.toDataURL('image/jpeg')
|
||||||
|
// Get the code to click the download link
|
||||||
|
aDownloadLink.click()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const onSizeLimitChange = (_sizeLimit: number) => {
|
const onSizeLimitChange = (_sizeLimit: number) => {
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import { useRecoilState } from 'recoil'
|
||||||
|
import { settingState } from '../../store/Atoms'
|
||||||
|
import { Switch, SwitchThumb } from '../shared/Switch'
|
||||||
|
import SettingBlock from './SettingBlock'
|
||||||
|
|
||||||
|
const DownloadMaskSettingBlock: React.FC = () => {
|
||||||
|
const [setting, setSettingState] = useRecoilState(settingState)
|
||||||
|
|
||||||
|
const onCheckChange = (checked: boolean) => {
|
||||||
|
setSettingState(old => {
|
||||||
|
return { ...old, downloadMask: checked }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<SettingBlock
|
||||||
|
title="Download Mask"
|
||||||
|
desc="Download inpainting result and mask"
|
||||||
|
input={
|
||||||
|
<Switch checked={setting.downloadMask} onCheckedChange={onCheckChange}>
|
||||||
|
<SwitchThumb />
|
||||||
|
</Switch>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default DownloadMaskSettingBlock
|
@ -17,7 +17,7 @@ function SettingBlock(props: SettingBlockProps) {
|
|||||||
<div className="setting-block-content-title">
|
<div className="setting-block-content-title">
|
||||||
<span>{title}</span>
|
<span>{title}</span>
|
||||||
{desc && (
|
{desc && (
|
||||||
<Tooltip content={<div style={{ width: 400 }}>{desc}</div>}>
|
<Tooltip content={<div style={{ maxWidth: 400 }}>{desc}</div>}>
|
||||||
<svg
|
<svg
|
||||||
width="18"
|
width="18"
|
||||||
height="18"
|
height="18"
|
||||||
|
@ -7,6 +7,7 @@ import ManualRunInpaintingSettingBlock from './ManualRunInpaintingSettingBlock'
|
|||||||
import HDSettingBlock from './HDSettingBlock'
|
import HDSettingBlock from './HDSettingBlock'
|
||||||
import ModelSettingBlock from './ModelSettingBlock'
|
import ModelSettingBlock from './ModelSettingBlock'
|
||||||
import GraduallyInpaintingSettingBlock from './GraduallyInpaintingSettingBlock'
|
import GraduallyInpaintingSettingBlock from './GraduallyInpaintingSettingBlock'
|
||||||
|
import DownloadMaskSettingBlock from './DownloadMaskSettingBlock'
|
||||||
|
|
||||||
interface SettingModalProps {
|
interface SettingModalProps {
|
||||||
onClose: () => void
|
onClose: () => void
|
||||||
@ -31,6 +32,7 @@ export default function SettingModal(props: SettingModalProps) {
|
|||||||
>
|
>
|
||||||
<ManualRunInpaintingSettingBlock />
|
<ManualRunInpaintingSettingBlock />
|
||||||
<GraduallyInpaintingSettingBlock />
|
<GraduallyInpaintingSettingBlock />
|
||||||
|
<DownloadMaskSettingBlock />
|
||||||
<ModelSettingBlock />
|
<ModelSettingBlock />
|
||||||
<HDSettingBlock />
|
<HDSettingBlock />
|
||||||
</Modal>
|
</Modal>
|
||||||
|
@ -32,6 +32,7 @@ export const shortcutsState = atom<boolean>({
|
|||||||
|
|
||||||
export interface Settings {
|
export interface Settings {
|
||||||
show: boolean
|
show: boolean
|
||||||
|
downloadMask: boolean
|
||||||
graduallyInpainting: boolean
|
graduallyInpainting: boolean
|
||||||
runInpaintingManually: boolean
|
runInpaintingManually: boolean
|
||||||
model: AIModel
|
model: AIModel
|
||||||
@ -49,6 +50,7 @@ export interface Settings {
|
|||||||
|
|
||||||
export const settingStateDefault = {
|
export const settingStateDefault = {
|
||||||
show: false,
|
show: false,
|
||||||
|
downloadMask: false,
|
||||||
graduallyInpainting: true,
|
graduallyInpainting: true,
|
||||||
runInpaintingManually: false,
|
runInpaintingManually: false,
|
||||||
model: AIModel.LAMA,
|
model: AIModel.LAMA,
|
||||||
|
Loading…
Reference in New Issue
Block a user