diff --git a/website/README.md b/website/README.md index ca0588a..8f63432 100644 --- a/website/README.md +++ b/website/README.md @@ -34,6 +34,8 @@ python3 -m http.server 8000 --bind 127.0.0.1 --directory dist/website | 规格说明 | Apple Silicon,macOS 26.0 或更新版本 | 视频需要 FFmpeg 和 ffprobe。图片转换可直接使用。 | | 开源说明 | [MIT 许可证](../LICENSE) · [第三方许可](../NOTICE.md) | 下载与源代码均指向官方 GitHub 仓库。 | +教程截图来自隔离的 WebKit 测试窗口,使用当前软件界面、编解码程序和青羽蜂鸟示例及其衍生素材。截图按语种保存于 `assets/tutorials/`,对应的替代文本和说明由 `guide-screens.mjs` 维护。点击截图可查看原尺寸。 + ### 页面信息 - 构建时从两份动图文件读取字节数,以十进制 KB、MB 显示体积并计算百分比。替换素材时同步更新三语 README、首帧海报和播放帧图。 diff --git a/website/assets/tutorials/gif-export-en.webp b/website/assets/tutorials/gif-export-en.webp new file mode 100644 index 0000000..cfee578 Binary files /dev/null and b/website/assets/tutorials/gif-export-en.webp differ diff --git a/website/assets/tutorials/gif-export-ja.webp b/website/assets/tutorials/gif-export-ja.webp new file mode 100644 index 0000000..87cf5ce Binary files /dev/null and b/website/assets/tutorials/gif-export-ja.webp differ diff --git a/website/assets/tutorials/gif-export-zh.webp b/website/assets/tutorials/gif-export-zh.webp new file mode 100644 index 0000000..76dfc73 Binary files /dev/null and b/website/assets/tutorials/gif-export-zh.webp differ diff --git a/website/assets/tutorials/sequence-delay-en.webp b/website/assets/tutorials/sequence-delay-en.webp new file mode 100644 index 0000000..6d6637b Binary files /dev/null and b/website/assets/tutorials/sequence-delay-en.webp differ diff --git a/website/assets/tutorials/sequence-delay-ja.webp b/website/assets/tutorials/sequence-delay-ja.webp new file mode 100644 index 0000000..a0ef366 Binary files /dev/null and b/website/assets/tutorials/sequence-delay-ja.webp differ diff --git a/website/assets/tutorials/sequence-delay-zh.webp b/website/assets/tutorials/sequence-delay-zh.webp new file mode 100644 index 0000000..5c046f4 Binary files /dev/null and b/website/assets/tutorials/sequence-delay-zh.webp differ diff --git a/website/assets/tutorials/sequence-reorder-en.webp b/website/assets/tutorials/sequence-reorder-en.webp new file mode 100644 index 0000000..ca4c8f1 Binary files /dev/null and b/website/assets/tutorials/sequence-reorder-en.webp differ diff --git a/website/assets/tutorials/sequence-reorder-ja.webp b/website/assets/tutorials/sequence-reorder-ja.webp new file mode 100644 index 0000000..a82413e Binary files /dev/null and b/website/assets/tutorials/sequence-reorder-ja.webp differ diff --git a/website/assets/tutorials/sequence-reorder-zh.webp b/website/assets/tutorials/sequence-reorder-zh.webp new file mode 100644 index 0000000..7ad170e Binary files /dev/null and b/website/assets/tutorials/sequence-reorder-zh.webp differ diff --git a/website/assets/tutorials/target-size-en.webp b/website/assets/tutorials/target-size-en.webp new file mode 100644 index 0000000..19f3eee Binary files /dev/null and b/website/assets/tutorials/target-size-en.webp differ diff --git a/website/assets/tutorials/target-size-ja.webp b/website/assets/tutorials/target-size-ja.webp new file mode 100644 index 0000000..af786be Binary files /dev/null and b/website/assets/tutorials/target-size-ja.webp differ diff --git a/website/assets/tutorials/target-size-zh.webp b/website/assets/tutorials/target-size-zh.webp new file mode 100644 index 0000000..b1e448e Binary files /dev/null and b/website/assets/tutorials/target-size-zh.webp differ diff --git a/website/assets/tutorials/video-export-en.webp b/website/assets/tutorials/video-export-en.webp new file mode 100644 index 0000000..a4490ac Binary files /dev/null and b/website/assets/tutorials/video-export-en.webp differ diff --git a/website/assets/tutorials/video-export-ja.webp b/website/assets/tutorials/video-export-ja.webp new file mode 100644 index 0000000..f3e8ac7 Binary files /dev/null and b/website/assets/tutorials/video-export-ja.webp differ diff --git a/website/assets/tutorials/video-export-zh.webp b/website/assets/tutorials/video-export-zh.webp new file mode 100644 index 0000000..29e074b Binary files /dev/null and b/website/assets/tutorials/video-export-zh.webp differ diff --git a/website/assets/tutorials/video-trim-en.webp b/website/assets/tutorials/video-trim-en.webp new file mode 100644 index 0000000..f92cd0e Binary files /dev/null and b/website/assets/tutorials/video-trim-en.webp differ diff --git a/website/assets/tutorials/video-trim-ja.webp b/website/assets/tutorials/video-trim-ja.webp new file mode 100644 index 0000000..7bce508 Binary files /dev/null and b/website/assets/tutorials/video-trim-ja.webp differ diff --git a/website/assets/tutorials/video-trim-zh.webp b/website/assets/tutorials/video-trim-zh.webp new file mode 100644 index 0000000..2b4c53a Binary files /dev/null and b/website/assets/tutorials/video-trim-zh.webp differ diff --git a/website/build.mjs b/website/build.mjs index aacddab..585f263 100644 --- a/website/build.mjs +++ b/website/build.mjs @@ -3,6 +3,7 @@ import { dirname, resolve, join } from "node:path"; import { fileURLToPath } from "node:url"; import { locales } from "./content.mjs"; import { guides } from "./guides.mjs"; +import { guideScreens, guideScreenshotPath, guideScreenshotSize } from "./guide-screens.mjs"; import { bytesPerKB, sizeText } from "../app/byte-size.js"; const here = dirname(fileURLToPath(import.meta.url)); @@ -17,7 +18,7 @@ const guideEntries = Object.entries(guides); const pageUrl = (t, leaf = "") => site + t.route + leaf; const pathPrefix = (t, leaf = "") => "../".repeat(Number(Boolean(t.route)) + Number(Boolean(leaf))) || "./"; const workspaceImage = key => "assets/workspace-" + key + ".png?v=hummingbird-kb"; -const versionedStyles = "style.css?v=6"; +const versionedStyles = "style.css?v=7"; const demoFiles = { gif: "docs/assets/hummingbird-loop.gif", webp: "docs/assets/hummingbird-loop.webp", @@ -208,6 +209,14 @@ function guidePage(key, t, slug, guide) { const steps = guide.steps.map(step => '
  • ' + escape(step) + '
  • ').join("\n"); const relatedSlug = guides[slug].related; const related = guides[relatedSlug][key]; + const { width, height } = guideScreenshotSize; + const figures = guideScreens[slug].map(scene => { + const [alt, caption] = scene[key]; + const path = prefix + guideScreenshotPath(scene.id, key); + return '
    ' + escape(alt) +
+      '
    ' + escape(caption) + '
    '; + }); return publicHead(key, t, { ...guide, title: guide.title + " | Any2WebP" }, leaf) + "\n" + [ "", '', @@ -219,6 +228,7 @@ function guidePage(key, t, slug, guide) { '
    ' + downloadButton(t) + '
    ', '

    ' + escape(t.requirement) + '

    ', '

    ' + escape(t.stepsHeading) + '

      ' + steps + '
    ', + ...figures, '

    ' + escape(guide.detailHeading) + '

    ' + escape(guide.detail) + '

    ', ' ', @@ -258,7 +268,15 @@ const assets = { "THIRD-PARTY-NOTICES.txt": "docs/THIRD-PARTY-NOTICES.txt", "LICENSE": "LICENSE", }; -await mkdir(join(output, "assets"), { recursive: true }); +for (const scenes of Object.values(guideScreens)) { + for (const scene of scenes) { + for (const [key] of translations) { + const path = guideScreenshotPath(scene.id, key); + assets[path] = "website/" + path; + } + } +} +await mkdir(join(output, "assets/tutorials"), { recursive: true }); await Promise.all(Object.entries(assets).map(([destination, source]) => copyFile(join(root, source), join(output, destination)))); for (const [key, t] of translations) { diff --git a/website/guide-screens.mjs b/website/guide-screens.mjs new file mode 100644 index 0000000..f834673 --- /dev/null +++ b/website/guide-screens.mjs @@ -0,0 +1,50 @@ +export const guideScreenshotSize = { width: 2480, height: 1556 }; + +export const guideScreens = { + "gif-to-webp": [ + { + id: "gif-export", + en: ["Side-by-side view of an original GIF and a WebP result in Any2WebP", "The lossless WebP export keeps the GIF’s frame delays, loop, and transparent background."], + zh: ["Any2WebP 中并排显示原 GIF 和 WebP 成品", "无损导出后,在成品信息中核对帧延时、播放次数和透明度。"], + ja: ["Any2WebP で元の GIF と WebP の書き出し結果を並べた画面", "可逆 WebP の書き出し後、出力情報で表示時間、再生回数、透過を確認できます。"], + }, + ], + "compress-webp": [ + { + id: "target-size", + en: ["Export settings showing a 500 KB target and output details showing the actual file size", "Enter 500 KB as the limit per file. After exporting, check the actual size and whether the target was met."], + zh: ["导出设置中的 500 KB 目标体积与成品的实际大小", "将单个文件的上限设为 500 KB,导出后检查实际大小及是否达标。"], + ja: ["目標サイズ 500 KB の設定と、書き出し結果の実際の容量", "上限に 500 KB を指定し、書き出し後の容量と目標サイズ以内かどうかを確認します。"], + }, + ], + "video-to-webp-gif": [ + { + id: "video-trim", + en: ["Video trim dialog showing the filmstrip and a selection from 8 to 12 seconds", "Use the handles on the timeline or enter start and end times to keep only the part you want."], + zh: ["视频剪切窗口的缩略图时间轴与 8 秒到 12 秒选区", "在时间轴上拖动起止手柄,也可以输入时间。本例保留第 8 秒到第 12 秒。"], + ja: ["動画トリミング画面のサムネイルと 8〜12 秒の選択範囲", "開始・終了ハンドルを動かすか、時刻を入力します。この例では 8 秒から 12 秒までを残します。"], + }, + { + id: "video-export", + en: ["Video export settings at 12 FPS and a 640 px long edge", "After trimming, set the frame rate and long edge below the preview. This WebP export has a 640 × 448 canvas."], + zh: ["预览下方的 12 FPS 帧率和 640 px 长边设置", "确认剪切后,在主窗口设置帧率和长边。本例导出的 WebP 画布为 640 × 448。"], + ja: ["プレビュー下の 12 FPS と長辺 640 px の設定", "トリミングを確定したら、フレームレートと長辺を設定します。この WebP の寸法は 640 × 448 です。"], + }, + ], + "images-to-webp-gif": [ + { + id: "sequence-reorder", + en: ["Frame editor showing thumbnails and an insertion marker before the second frame", "Drag the sixth thumbnail before the second one. The blue line marks where it will go."], + zh: ["帧编辑器的缩略图和第二帧前的拖动插入线", "将第六张缩略图拖到第二帧之前,蓝线标出松手后的插入位置。"], + ja: ["フレーム編集画面のサムネイルと、2 枚目の手前の挿入位置", "6 枚目を 2 枚目の手前にドラッグします。青い線が挿入位置を示します。"], + }, + { + id: "sequence-delay", + en: ["Frame editor with the final thumbnail selected and its duration set to 500 ms", "After applying a uniform frame rate, select the last frame and set its duration to 500 ms."], + zh: ["帧编辑器选中末帧,单帧停留时间为 500 ms", "应用统一帧率后,选中最后一帧,将单帧停留时间改为 500 ms。"], + ja: ["最後のフレームを選択し、表示時間を 500 ms にした画面", "一定のフレームレートを適用してから、最後のフレームだけを 500 ms に設定します。"], + }, + ], +}; + +export const guideScreenshotPath = (id, locale) => "assets/tutorials/" + id + "-" + locale + ".webp"; diff --git a/website/style.css b/website/style.css index b38e681..8f36f74 100644 --- a/website/style.css +++ b/website/style.css @@ -148,6 +148,10 @@ figcaption span { white-space: nowrap; color: var(--muted); } .guide h2 { margin: 36px 0 12px; font-size: 1.4rem; } .guide ol { padding-inline-start: 1.4em; margin: 0; } .guide li + li { margin-top: 10px; } +.guide-shot { margin-top: 22px; } +.guide-shot a { display: block; border-radius: 10px; } +.guide-shot img { width: 100%; border: 1px solid var(--line); border-radius: inherit; } +.guide-shot figcaption { display: block; padding: 6px 0 0; color: var(--muted); font-size: .9rem; } .guide-related { margin: 22px 0 0; padding-inline-start: 1.4em; } @media (max-width: 640px) { .guide-links { grid-template-columns: 1fr; } diff --git a/website/verify.mjs b/website/verify.mjs index 0726dcd..532b7b7 100644 --- a/website/verify.mjs +++ b/website/verify.mjs @@ -1,6 +1,7 @@ import assert from "node:assert/strict"; import { readFile } from "node:fs/promises"; import { resolve } from "node:path"; +import { guideScreens, guideScreenshotPath, guideScreenshotSize } from "./guide-screens.mjs"; const output = resolve(process.argv[2] || "dist/website"); const read = file => readFile(resolve(output, file), "utf8"); @@ -57,6 +58,18 @@ for (const [lang, route] of languages) { assert.ok(html.includes('href="../#formats"')); assert.ok(html.includes('href="../' + guides[page] + '"')); assert.doesNotMatch(html, /]* alt="([^"]+)"><\/a>
    ([^<]+)<\/figcaption><\/figure>/g)]; + assert.equal(images.length, shots.length); + for (const [index, [, link, src]] of images.entries()) { + const path = guideScreenshotPath(shots[index].id, locale); + assert.equal(new URL(link, url).href, site + path); + assert.equal(link, src); + const asset = await readFile(resolve(output, path)); + assert.equal(asset.toString("ascii", 8, 12), "WEBP"); + } + assert.ok(html.includes('width="' + guideScreenshotSize.width + '" height="' + guideScreenshotSize.height + '"')); } else { const hero = html.match(/
    ]*>([\s\S]*?)<\/section>/)?.[1]; const online = html.match(/
    ]*>([\s\S]*?)<\/section>/)?.[1];