Skip to content

Conversation

@lukemelia
Copy link
Contributor

@lukemelia lukemelia commented Feb 2, 2026

Summary

  • Introduce ImageDef (extends FileDef) with four format components: isolated, embedded, atom, and fitted
  • Add PngDef — PNG dimension extraction via png-meta-extractor
  • Add JpgDef — JPEG dimension extraction via jpg-meta-extractor (scans SOF markers)
  • Add SvgDef — SVG dimension extraction via svg-meta-extractor (explicit attrs + viewBox fallback)
  • Add GifDef — GIF dimension extraction via gif-meta-extractor (GIF87a/GIF89a)
  • Add WebpDef — WebP dimension extraction via webp-meta-extractor (VP8, VP8L, VP8X)
  • Register .png, .jpg, .jpeg, .svg, .gif, and .webp extensions in FILEDEF_CODE_REF_BY_EXTENSION
  • Includes acceptance tests for all formats covering extraction, rendering, indexing, and fallback handling

Test plan

  • Run png-image-def acceptance tests
  • Run jpg-image-def acceptance tests
  • Run svg-image-def acceptance tests (including viewBox-only)
  • Run gif-image-def acceptance tests
  • Run webp-image-def acceptance tests

🤖 Generated with Claude Code

@github-actions
Copy link

github-actions bot commented Feb 2, 2026

Preview deployments

@github-actions
Copy link

github-actions bot commented Feb 2, 2026

Host Test Results

    1 files  ± 0      1 suites  ±0   1h 40m 13s ⏱️ - 2m 18s
1 837 tests +36  1 824 ✅ +49  13 💤 ±0  0 ❌ ± 0 
1 852 runs  +36  1 839 ✅ +62  13 💤 ±0  0 ❌  - 13 

Results for commit 24c6db5. ± Comparison against base commit 8bfef78.

♻️ This comment has been updated with latest results.

@lukemelia lukemelia force-pushed the cs-9912-implement-pngimagedef branch from e93d5eb to 24cf925 Compare February 3, 2026 16:08
@lukemelia lukemelia changed the title Add ImageDef/PngDef with format components and PNG metadata extraction Add ImageDef/PngDef/JpgDef with format components and image metadata extraction Feb 4, 2026
@lukemelia lukemelia changed the title Add ImageDef/PngDef/JpgDef with format components and image metadata extraction Add ImageDef/PngDef/JpgDef/SvgDef with format components and image metadata extraction Feb 4, 2026
@lukemelia lukemelia changed the title Add ImageDef/PngDef/JpgDef/SvgDef with format components and image metadata extraction Add ImageDef with PngDef, JpgDef, SvgDef, GifDef, and WebpDef Feb 4, 2026
@lukemelia lukemelia mentioned this pull request Feb 10, 2026
2 tasks
@lukemelia lukemelia force-pushed the cs-9912-implement-pngimagedef branch from b200fbf to d28e87d Compare February 10, 2026 15:53
lukemelia and others added 15 commits February 10, 2026 11:40
Introduce ImageDef (extends FileDef) with isolated, embedded, atom, and
fitted format components, and PngDef (extends ImageDef) with PNG dimension
extraction. The atom format shows a small thumbnail with the file name,
embedded renders the image at container width with natural height, and
fitted uses a CSS background-image to cover available space. Includes
a PNG metadata extractor and acceptance tests.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The check at line 277 was unreachable since Uint8Array is already
handled at line 258 in the if-else chain.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Tests were using string content for .png files which caused the PNG
extractor to fail and fall back to ImageDef. Updated tests to use
actual PNG binary data so PngDef extraction succeeds.

- Add makeMinimalPng helper to test helpers
- Update card-basics-test to use valid PNG bytes
- Update card-endpoints-test to use valid PNG bytes and expect PngDef

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The FileDef render tests were using .png files, but with the new PngDef
implementation, PNG files are indexed as PngDef/ImageDef which renders
a background image instead of showing the filename as text. Changed to
.txt files so the tests properly verify FileDef's text-based rendering.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add readFirstBytes() utility that reads only the first N bytes from a
ByteStream, then cancels the remainder. Use it in image defs so dimension
extraction reads only what each format needs (24B for PNG, 10B for GIF,
30B for WebP, 64KB for JPEG/AVIF) instead of buffering the full file.
SVG still reads fully since it needs text parsing.

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

Replace the O(n) byte-by-byte scan for the ispe marker with proper
ISOBMFF box-tree walking (meta → iprp → ipco → ispe). This is both
faster and eliminates false matches on "ispe" appearing in pixel data.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@lukemelia lukemelia force-pushed the cs-9912-implement-pngimagedef branch from 32dbda1 to 2691d54 Compare February 10, 2026 16:40
lukemelia and others added 2 commits February 10, 2026 14:03
Browser-native <img> requests bypass VirtualNetwork, so a test service
worker (test-realm-sw.js) now intercepts requests to the test realm URL
and relays them through VirtualNetwork via postMessage.

Also fixes the realm's fallbackHandle to set Content-Type via
inferContentType for non-module static files, and replaces minimal
header-only test images (JPG, WebP) with real browser-decodable binaries
so naturalWidth/naturalHeight assertions work. AVIF uses a two-file
approach: makeMinimalAvif for extraction tests and canvas.toBlob for
the authenticated display test.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@lukemelia lukemelia requested review from a team and backspace February 10, 2026 20:00
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