feat: overhaul upscale with bug fixes and advanced features

- Fix multi-image: process selected file, not always first
- Fix progress bar: asymptotic fill prevents visual stalling
- Fix slider: write results to captured index, not current selection
- Add model selection (Auto/AI/Fast), face enhancement, denoise
- Add output format (PNG/JPEG/WebP) with quality control
- Add Upscale All for sequential batch processing with queue
- More granular Python progress stages for smoother UX
This commit is contained in:
Siddharth Kumar Sah
2026-04-12 19:04:23 +08:00
parent 7995d13c81
commit fe376aebd2
4 changed files with 367 additions and 71 deletions
+10 -4
View File
@@ -56,8 +56,13 @@ export function registerUpscale(app: FastifyInstance) {
try {
const settings = settingsRaw ? JSON.parse(settingsRaw) : {};
const scale = Number(settings.scale) || 2;
const model = settings.model || "auto";
const faceEnhance = Boolean(settings.faceEnhance);
const denoise = Number(settings.denoise) || 0;
const format = settings.format || "png";
const outputQuality = Number(settings.quality) || 95;
request.log.info(
{ toolId: "upscale", imageSize: fileBuffer.length, scale },
{ toolId: "upscale", imageSize: fileBuffer.length, scale, model, format },
"Starting upscale",
);
@@ -87,12 +92,13 @@ export function registerUpscale(app: FastifyInstance) {
const result = await upscale(
fileBuffer,
join(workspacePath, "output"),
{ scale },
{ scale, model, faceEnhance, denoise, format, quality: outputQuality },
onProgress,
);
// Save output
const outputFilename = `${filename.replace(/\.[^.]+$/, "")}_${scale}x.png`;
// Save output with correct extension for the chosen format
const ext = result.format === "jpeg" ? "jpg" : result.format === "webp" ? "webp" : "png";
const outputFilename = `${filename.replace(/\.[^.]+$/, "")}_${scale}x.${ext}`;
const outputPath = join(workspacePath, "output", outputFilename);
await writeFile(outputPath, result.buffer);