${r.name}
${(r.size/1024).toFixed(0)} KB
${s>0?'↓':'↑'}${Math.abs(s)}%
${r.dims}
`;
document.getElementById('resGrid').appendChild(card);
document.getElementById('resultsSection').style.display = 'block';
}
function dlOne(id) {
const r = results.find(x => String(x.id) === String(id));
if (!r) return;
const a = document.createElement('a');
a.href = URL.createObjectURL(r.blob);
a.download = r.name;
a.click();
}
async function downloadAll() {
if (!results.length) return;
const zip = new JSZip();
results.forEach(r => zip.file(r.name, r.blob));
const blob = await zip.generateAsync({ type: 'blob' });
const a = document.createElement('a');
a.href = URL.createObjectURL(blob);
a.download = 'imgflow_pipeline.zip';
a.click();
}
// ═══════════════════════════════════════
// PRESETS
// ═══════════════════════════════════════
function applyPreset(p) {
document.querySelectorAll('.preset-btn').forEach(b => b.classList.toggle('active', b.dataset.preset === p));
if (p === 'quick') {
document.getElementById('upscaleMethod').value = 'bicubic';
document.getElementById('upscaleFactor').value = '2';
document.getElementById('webpQ').value = 75; document.getElementById('qv').textContent = 75;
document.getElementById('maxKB').value = 300;
} else if (p === 'balanced') {
document.getElementById('upscaleMethod').value = 'lanczos';
document.getElementById('upscaleFactor').value = '2';
document.getElementById('webpQ').value = 85; document.getElementById('qv').textContent = 85;
document.getElementById('maxKB').value = 500;
} else {
document.getElementById('upscaleMethod').value = 'lanczos';
document.getElementById('upscaleFactor').value = '3';
document.getElementById('webpQ').value = 95; document.getElementById('qv').textContent = 95;
document.getElementById('maxKB').value = 2000;
}
}
// ═══════════════════════════════════════
// INIT
// ═══════════════════════════════════════
renderTrack();