mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2024-11-23 08:43:42 +01:00
Fixed showImages to clone batched reqBody and not reuse same objects.
This commit is contained in:
parent
27e372e38f
commit
324c8f8146
@ -303,22 +303,16 @@ function resizeInpaintingEditor() {
|
|||||||
inpaintingEditor.setColor(inpaintingEditor.opts.color)
|
inpaintingEditor.setColor(inpaintingEditor.opts.color)
|
||||||
}
|
}
|
||||||
|
|
||||||
function showImages(req, res, outputContainer, livePreview) {
|
function showImages(reqBody, res, outputContainer, livePreview) {
|
||||||
let imageItemElements = outputContainer.querySelectorAll('.imgItem')
|
let imageItemElements = outputContainer.querySelectorAll('.imgItem')
|
||||||
|
|
||||||
res.output.reverse()
|
|
||||||
|
|
||||||
res.output.forEach((result, index) => {
|
|
||||||
if(typeof res != 'object') return
|
if(typeof res != 'object') return
|
||||||
|
res.output.reverse()
|
||||||
const imageData = result?.data || result?.path + '?t=' + new Date().getTime(),
|
res.output.forEach((result, index) => {
|
||||||
imageSeed = result?.seed,
|
const imageData = result?.data || result?.path + '?t=' + new Date().getTime()
|
||||||
imageWidth = req.width,
|
const imageWidth = reqBody.width
|
||||||
imageHeight = req.height;
|
const imageHeight = reqBody.height
|
||||||
|
|
||||||
if (!imageData.includes('/')) {
|
if (!imageData.includes('/')) {
|
||||||
// res contained no data for the image, stop execution
|
// res contained no data for the image, stop execution
|
||||||
|
|
||||||
setStatus('request', 'invalid image', 'error')
|
setStatus('request', 'invalid image', 'error')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -335,6 +329,23 @@ function showImages(req, res, outputContainer, livePreview) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
|
outputContainer.appendChild(imageItemElem)
|
||||||
|
}
|
||||||
|
const imageElem = imageItemElem.querySelector('img')
|
||||||
|
imageElem.src = imageData
|
||||||
|
imageElem.width = parseInt(imageWidth)
|
||||||
|
imageElem.height = parseInt(imageHeight)
|
||||||
|
const imageInfo = imageItemElem.querySelector('.imgItemInfo')
|
||||||
|
imageInfo.style.visibility = (livePreview ? 'hidden' : 'visible')
|
||||||
|
|
||||||
|
if ('seed' in result && !imageElem.hasAttribute('data-seed')) {
|
||||||
|
const req = Object.assign({}, reqBody, {
|
||||||
|
seed: result?.seed || reqBody.seed
|
||||||
|
})
|
||||||
|
imageElem.setAttribute('data-seed', req.seed)
|
||||||
|
const imageSeedLabel = imageItemElem.querySelector('.imgSeedLabel')
|
||||||
|
imageSeedLabel.innerText = 'Seed: ' + req.seed
|
||||||
|
|
||||||
const buttons = {
|
const buttons = {
|
||||||
'imgUseBtn': { html: 'Use as Input', click: getUseAsInputHandler(imageItemElem) },
|
'imgUseBtn': { html: 'Use as Input', click: getUseAsInputHandler(imageItemElem) },
|
||||||
'imgSaveBtn': { html: 'Download', click: getSaveImageHandler(imageItemElem, req['output_format']) },
|
'imgSaveBtn': { html: 'Download', click: getSaveImageHandler(imageItemElem, req['output_format']) },
|
||||||
@ -353,21 +364,7 @@ function showImages(req, res, outputContainer, livePreview) {
|
|||||||
imgItemInfo.appendChild(newButton)
|
imgItemInfo.appendChild(newButton)
|
||||||
}
|
}
|
||||||
Object.keys(buttons).forEach((name) => createButton(name, buttons[name]))
|
Object.keys(buttons).forEach((name) => createButton(name, buttons[name]))
|
||||||
outputContainer.appendChild(imageItemElem)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const imageElem = imageItemElem.querySelector('img')
|
|
||||||
const imageSeedLabel = imageItemElem.querySelector('.imgSeedLabel')
|
|
||||||
|
|
||||||
imageElem.src = imageData
|
|
||||||
imageElem.width = parseInt(imageWidth)
|
|
||||||
imageElem.height = parseInt(imageHeight)
|
|
||||||
imageElem.setAttribute('data-seed', imageSeed)
|
|
||||||
|
|
||||||
const imageInfo = imageItemElem.querySelector('.imgItemInfo')
|
|
||||||
imageInfo.style.visibility = (livePreview ? 'hidden' : 'visible')
|
|
||||||
|
|
||||||
imageSeedLabel.innerText = 'Seed: ' + imageSeed
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user