Skip to content

Add get_image_metadata() with JPEG support - #1788

Merged
NicolasHug merged 4 commits into
mainfrom
image_metadata_1_jpeg
Oct 28, 2026
Merged

NicolasHug merged 4 commits into
mainfrom
image_metadata_1_jpeg

Conversation

@NicolasHug

@NicolasHug NicolasHug commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

First of various PRs to add image metadata probing. This one is for JPEG. The probes are 100% vibed, obviously. Some will be in Python, some will be in C++, depending on benchmark results on small and large image files.


Adds get_image_metadata(source) -> ImageMetadata(format, width, height, num_channels, bit_depth, num_frames, rotation), which parses the image headers without decoding. Every field describes the output of the decoders: post-rotation width/height, channels with mode="UNCHANGED", bit_depth > 8 iff output_dtype="auto" returns uint16, and rotation with the same convention as VideoStreamMetadata.rotation.


Stack created with GitHub Stacks CLI • Give Feedback 💬

@pytorch-bot

pytorch-bot Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/meta-pytorch/torchcodec/1788

Note: Links to docs will display an error until the docs builds have been completed.

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 27, 2026
@NicolasHug
NicolasHug added this pull request to stack #1794 October 27, 2026 19:04
Adds get_image_metadata(source) -> ImageMetadata(format, width, height, num_channels, bit_depth, num_frames, rotation), which parses the image headers without decoding. Every field describes the output of the decoders: post-rotation width/height, channels with mode="UNCHANGED", bit_depth > 8 iff output_dtype="auto" returns uint16, and rotation with the same convention as VideoStreamMetadata.rotation. Paths are read lazily, so only the headers are read. This PR adds the core and JPEG support, parsed in Python (faster than calling into libjpeg).
@NicolasHug
NicolasHug force-pushed the image_metadata_1_jpeg branch from b3b42d6 to b808c75 Compare October 28, 2026 10:40
Comment thread test/test_samplers.py
# is constant.
for diff in seconds_between_clip_starts:
assert diff == pytest.approx(seconds_between_clip_starts[0], abs=0.05)
assert diff == pytest.approx(seconds_between_clip_starts[0].item(), abs=0.05)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drive for new pytest version which tries to iterate on this 0-d tensor (ugh)

@NicolasHug
NicolasHug marked this pull request as ready for review October 28, 2026 11:14
@NicolasHug
NicolasHug merged commit 61c2f48 into main Oct 28, 2026
29 checks passed
This was referenced Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant