perf(vishot): compress and downscale AVIF screenshots (#1598)

* perf(vishot-runner-electron): compress and downscale AVIF screenshots

The capture pipeline was emitting AVIF at default quality with no
resolution cap, so 4K displays produced ~800KB per screenshot (~42MB
total for the tamagotchi manual). Add quality 50, speed 6, and a
1920px max-width downscale — expected output drops to ~20-40KB each
with no visible quality loss for UI documentation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* perf(docs): regenerate manual screenshots with compression

Re-capture all 27 tamagotchi manual screenshots using the new AVIF
pipeline settings (quality 50, max-width 1920px, speed 6).

Before: ~800KB per image, ~42MB total (4K @ default quality)
After:  ~15-38KB per image, ~1MB total (1920px @ quality 50)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By-Agent: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Lovehsigure_520
2026-04-08 10:11:18 +08:00
committed by GitHub
co-authored by Claude Opus 4.6
parent 52eff227de
commit 7b1041fa8e
55 changed files with 21 additions and 1 deletions
@@ -18,6 +18,13 @@ import { resolveElectronAppInfo } from '../utils/app-path'
type CaptureFormat = 'png' | 'avif'
/** Max width for AVIF output — anything wider is downscaled proportionally. */
const AVIF_MAX_WIDTH = 1920
/** AVIF quality (0-100, 100 = lossless). 50 is nearly indistinguishable for UI screenshots. */
const AVIF_QUALITY = 50
/** rav1e speed preset (1 = slow/best, 10 = fast/worst). 6 balances size vs encode time. */
const AVIF_SPEED = 6
interface CaptureCliArguments {
scenarioPath: string
outputDir: string
@@ -69,7 +76,20 @@ function createAvifTransformer(): ArtifactTransformer {
return async (artifact) => {
// eslint-disable-next-line e18e/prefer-static-regex
const derivedFilePath = artifact.filePath.replace(/\.png$/i, '.avif')
const avifBuffer = await new Transformer(await readFile(artifact.filePath)).avif()
const transformer = new Transformer(await readFile(artifact.filePath))
const metadata = await transformer.metadata()
// Downscale images wider than AVIF_MAX_WIDTH, keeping aspect ratio
if (metadata.width > AVIF_MAX_WIDTH) {
const scale = AVIF_MAX_WIDTH / metadata.width
transformer.resize(AVIF_MAX_WIDTH, Math.round(metadata.height * scale))
}
const avifBuffer = await transformer.avif({
quality: AVIF_QUALITY,
speed: AVIF_SPEED,
})
await writeFile(derivedFilePath, avifBuffer)
await rm(artifact.filePath, { force: true })