Skip to content

feat(jpeg): the JPEG lab's engine lab and stages 1–4 - #39

Merged
benjamin-small merged 14 commits into
mainfrom
jpeg-lab-stages
Oct 16, 2026
Merged

benjamin-small merged 14 commits into
mainfrom
jpeg-lab-stages

Conversation

@benjamin-small

Copy link
Copy Markdown
Owner

Slice 2 of the JPEG compression lab: the engine lab and stages 1–4 at #/jpeg. The lab isn't linked from the nav or home page yet; that comes in slice 4.

  • Spec: docs/superpowers/specs/2026-10-15-jpeg-lab-design.md (see the Plan 2 amendment)
  • Plan: docs/superpowers/plans/2026-10-16-jpeg-lab-2-stages.md

What's in it

Engine

  • Three generic hooks: update_rule_config_with_image (pixels as a typed array), rule_inspect, rule_bytes. They don't change any other lab.

jpeg rule

  • One encode per config; the engine clock walks the scan MCU by MCU.
  • select_block is the only action.
  • The first selection is the block with the most detail.

Visualization

  • A TextureQuad renderer, and JpegViz, which draws whatever panels the page lays out (with optional zoom crops).

Page

  • A nine-step pipeline rail.
  • Image controls: built-ins, upload, quality, chroma and Huffman; settings changes re-encode and restore the scan position.
  • Readout and Save .jpg.
  • Stages 1–4 with live formulas:
    • Color: a rotating colour cube from RGB to YCbCr axes.
    • Subsample: zoomed chroma, as measured next to as kept.
    • Blocks: the block grid and the selected block's numbers.
    • DCT: basis atlas, coefficients, a k-term rebuild, energy curve and "why cosines?".
  • Share links: img, q, s, h, stage, b.
  • Keyboard: the arrow keys move between stages, and move the block when the image is focused.

Tests

  • cargo test --all-features: jpeg 85, viz-core 293.
  • wasm-pack test --chrome --headless: 46.
  • Vitest: 478.
  • fmt, clippy (no new warnings) and svelte-check are clean.
  • Checked in the browser at 1440 and 375 px, light and dark.

@benjamin-small
benjamin-small merged commit c186d3e into main Oct 16, 2026
6 checks passed
@benjamin-small
benjamin-small deleted the jpeg-lab-stages branch October 16, 2026 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant