Added upscale options
This commit is contained in:
parent
7de3a268e9
commit
556ec5cb7b
2 changed files with 17 additions and 4 deletions
|
@ -294,8 +294,11 @@
|
||||||
<label>Choose upscaler</label>
|
<label>Choose upscaler</label>
|
||||||
<div id="upscaler-ac-select"></div>
|
<div id="upscaler-ac-select"></div>
|
||||||
<div id="upscaleX"></div>
|
<div id="upscaleX"></div>
|
||||||
<button onclick="upscaleAndDownload()">
|
<button onclick="upscaleAndDownload(true,false)">
|
||||||
Upscale (might take a sec)
|
Upscale (and download)
|
||||||
|
</button>
|
||||||
|
<button onclick="upscaleAndDownload(false,true)">
|
||||||
|
Upscale (to resource)
|
||||||
</button>
|
</button>
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
|
14
js/index.js
14
js/index.js
|
@ -1430,7 +1430,7 @@ async function getSamplers() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function upscaleAndDownload() {
|
async function upscaleAndDownload(download = false, add_resource = false) {
|
||||||
// Future improvements: some upscalers take a while to upscale, so we should show a loading bar or something, also a slider for the upscale amount
|
// Future improvements: some upscalers take a while to upscale, so we should show a loading bar or something, also a slider for the upscale amount
|
||||||
|
|
||||||
// get cropped canvas, send it to upscaler, download result
|
// get cropped canvas, send it to upscaler, download result
|
||||||
|
@ -1481,7 +1481,17 @@ async function upscaleAndDownload() {
|
||||||
upscale_factor +
|
upscale_factor +
|
||||||
".png";
|
".png";
|
||||||
link.href = "data:image/png;base64," + data["image"];
|
link.href = "data:image/png;base64," + data["image"];
|
||||||
link.click();
|
|
||||||
|
if (add_resource == true) {
|
||||||
|
console.log("Add upscaled to resource")
|
||||||
|
const img = new Image();
|
||||||
|
img.src = link.href;
|
||||||
|
tools.stamp.state.addResource("Upscaled image", img);
|
||||||
|
}
|
||||||
|
if (download == true){
|
||||||
|
console.log("Download upscaled")
|
||||||
|
link.click();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue