-
Notifications
You must be signed in to change notification settings - Fork 12
Add ImageDef with PngDef, JpgDef, SvgDef, GifDef, and WebpDef #3939
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lukemelia
wants to merge
17
commits into
main
Choose a base branch
from
cs-9912-implement-pngimagedef
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,661
−26
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Preview deployments |
e93d5eb to
24cf925
Compare
2 tasks
b200fbf to
d28e87d
Compare
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>
32dbda1 to
2691d54
Compare
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>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
ImageDef(extendsFileDef) with four format components: isolated, embedded, atom, and fittedPngDef— PNG dimension extraction viapng-meta-extractorJpgDef— JPEG dimension extraction viajpg-meta-extractor(scans SOF markers)SvgDef— SVG dimension extraction viasvg-meta-extractor(explicit attrs + viewBox fallback)GifDef— GIF dimension extraction viagif-meta-extractor(GIF87a/GIF89a)WebpDef— WebP dimension extraction viawebp-meta-extractor(VP8, VP8L, VP8X).png,.jpg,.jpeg,.svg,.gif, and.webpextensions inFILEDEF_CODE_REF_BY_EXTENSIONTest plan
png-image-defacceptance testsjpg-image-defacceptance testssvg-image-defacceptance tests (including viewBox-only)gif-image-defacceptance testswebp-image-defacceptance tests🤖 Generated with Claude Code