fix(image-manipulator): prevent excessive WebP compression and preserve crisp resolution with cwebp Sharp-YUV and quality controls
This commit is contained in:
@@ -1231,6 +1231,12 @@ function renderToolOptions() {
|
||||
<button class="seg-pill ${toolState.convert.format==='bmp'?'active':''}" onclick="setConvertFormat('bmp')">BMP</button>
|
||||
<button class="seg-pill ${toolState.convert.format==='tiff'?'active':''}" onclick="setConvertFormat('tiff')">TIFF</button>
|
||||
</div>
|
||||
<div class="ps-options-group" id="opt-convert-q-group" style="${(toolState.convert.format==='webp'||toolState.convert.format==='jpg'||toolState.convert.format==='avif')?'display:flex;align-items:center;':'display:none;'}">
|
||||
<span class="ps-options-label">Quality:</span>
|
||||
<input type="range" min="50" max="100" value="${toolState.convert.quality}" style="width: 110px;" oninput="updateConvertQuality(this.value)">
|
||||
<span class="label-val" id="opt-conv-val">${toolState.convert.quality}%</span>
|
||||
<span style="font-size: 10px; color: var(--accent-cyan); font-family: var(--font-mono); margin-left: 4px;">${toolState.convert.quality>=95?'(High Res)':toolState.convert.quality>=85?'(Balanced)':'' }</span>
|
||||
</div>
|
||||
`,
|
||||
compress: `
|
||||
<div class="ps-options-group">
|
||||
@@ -1465,10 +1471,10 @@ function renderToolControls() {
|
||||
<div class="ps-section-title">Transcode Format</div>
|
||||
<div class="input-group">
|
||||
<label>Target Extension</label>
|
||||
<select id="param-format" onchange="toolState.convert.format=this.value">
|
||||
<select id="param-format" onchange="toolState.convert.format=this.value; renderToolOptions();">
|
||||
<option value="png" ${toolState.convert.format==='png'?'selected':''}>PNG (Lossless)</option>
|
||||
<option value="jpg" ${toolState.convert.format==='jpg'?'selected':''}>JPG (Standard Web)</option>
|
||||
<option value="webp" ${toolState.convert.format==='webp'?'selected':''}>WEBP (High Efficiency)</option>
|
||||
<option value="webp" ${toolState.convert.format==='webp'?'selected':''}>WEBP (High Efficiency & Crisp)</option>
|
||||
<option value="avif" ${toolState.convert.format==='avif'?'selected':''}>AVIF (Modern Ultra-Compressed)</option>
|
||||
<option value="bmp" ${toolState.convert.format==='bmp'?'selected':''}>BMP (Windows Bitmap)</option>
|
||||
<option value="tiff" ${toolState.convert.format==='tiff'?'selected':''}>TIFF (Print Master)</option>
|
||||
@@ -1480,6 +1486,9 @@ function renderToolControls() {
|
||||
<label>Quality Profile (1-100) <span class="label-val" id="val-conv-q">${toolState.convert.quality}%</span></label>
|
||||
<input type="range" id="param-quality" min="1" max="100" value="${toolState.convert.quality}" oninput="updateConvertQuality(this.value)">
|
||||
</div>
|
||||
<div style="background: var(--bg-input); border: 1px solid var(--border-1); border-radius: var(--r-md); padding: 10px; font-size: 11px; color: var(--text-3); line-height: 1.4;">
|
||||
<i class="fa-solid fa-circle-check" style="color: var(--accent-emerald);"></i> <b>Crisp WebP Transcoding:</b> Powered by Google's native <code>cwebp</code> engine with Sharp-YUV color preservation. Retains full resolution and fine texture without blur (quality 92–98 recommended, 100 for lossless).
|
||||
</div>
|
||||
`,
|
||||
compress: `
|
||||
<div class="ps-section-title">Compression Engine</div>
|
||||
@@ -1487,7 +1496,7 @@ function renderToolControls() {
|
||||
<label>Output Format</label>
|
||||
<select id="param-format" onchange="updateCompressFormat(this.value)">
|
||||
<option value="original" ${toolState.compress.format==='original'?'selected':''}>Preserve Original Format</option>
|
||||
<option value="webp" ${toolState.compress.format==='webp'?'selected':''}>WEBP (Maximum Reduction)</option>
|
||||
<option value="webp" ${toolState.compress.format==='webp'?'selected':''}>WEBP (High Efficiency & Crisp)</option>
|
||||
<option value="jpg" ${toolState.compress.format==='jpg'?'selected':''}>JPG (Web Optimized)</option>
|
||||
<option value="png" ${toolState.compress.format==='png'?'selected':''}>PNG (Lossless Graphics)</option>
|
||||
</select>
|
||||
@@ -1731,6 +1740,10 @@ function updateConvertQuality(val) {
|
||||
toolState.convert.quality = q;
|
||||
const l = document.getElementById("val-conv-q");
|
||||
if (l) l.innerText = `${q}%`;
|
||||
const lOpt = document.getElementById("opt-conv-val");
|
||||
if (lOpt) lOpt.innerText = `${q}%`;
|
||||
const pQ = document.getElementById("param-quality");
|
||||
if (pQ && pQ.value != q) pQ.value = q;
|
||||
}
|
||||
window.updateConvertQuality = updateConvertQuality;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user