resize image using backend;add resize radio button

frontend resize image will reduce image quality
This commit is contained in:
Qing
2021-11-27 20:37:37 +08:00
committed by Sanster
parent 1c2e7fa559
commit 1e2c8fd348
9 changed files with 163 additions and 144 deletions

View File

@@ -2,12 +2,23 @@ import { dataURItoBlob } from '../utils'
export const API_ENDPOINT = `${process.env.REACT_APP_INPAINTING_URL}/inpaint`
export default async function inpaint(imageFile: File, maskBase64: string) {
export default async function inpaint(
imageFile: File,
maskBase64: string,
sizeLimit?: string
) {
// 1080, 2000, Original
const fd = new FormData()
fd.append('image', imageFile)
const mask = dataURItoBlob(maskBase64)
fd.append('mask', mask)
if (sizeLimit === undefined) {
fd.append('sizeLimit', '1080')
} else {
fd.append('sizeLimit', sizeLimit)
}
const res = await fetch(API_ENDPOINT, {
method: 'POST',
body: fd,