Skip to content
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

Fix JPEG image size determination #12542

Merged
merged 2 commits into from
Nov 27, 2024
Merged

Fix JPEG image size determination #12542

merged 2 commits into from
Nov 27, 2024

Conversation

kadykov
Copy link
Contributor

@kadykov kadykov commented Nov 27, 2024

Fixes #12530

Changes

  • Fixed incorrect handling of non-0xFF blocks in the JPEG image size calculation. Instead of skipping one byte, the entire block is now skipped, improving performance and accuracy.
  • Before this change, the code would incorrectly enter and parse non-0xFF blocks, leading to incorrect image size determination. This change ensures that only valid JPEG blocks are processed, skipping unnecessary metadata blocks.

Testing

This change was tested manually by verifying that the image size calculation is accurate for JPEG images with various metadata blocks. No new tests were added, as the existing tests should cover this scenario.

Docs

This change does not affect user behavior, so no documentation updates are required. The fix is internal to the JPEG image size calculation logic and does not introduce any new features or APIs.

Copy link

changeset-bot bot commented Nov 27, 2024

🦋 Changeset detected

Latest commit: 6c4ad21

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Nov 27, 2024
Copy link

codspeed-hq bot commented Nov 27, 2024

CodSpeed Performance Report

Merging #12542 will not alter performance

Comparing kadykov:jpeg-size (6c4ad21) with main (cf0d8b0)

Summary

✅ 6 untouched benchmarks

@Princesseuh
Copy link
Member

Princesseuh commented Nov 27, 2024

This folder is a vendored version of image-size (we have not written any of the code in it), I would suggest sending a PR there as well: https://github.com/image-size/image-size

Since the upstream package here is rarely updated, it should be fine to update our copy, though

Copy link
Member

@Princesseuh Princesseuh left a comment

Choose a reason for hiding this comment

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

Code looks great, thank you!

@ematipico ematipico merged commit 65e50eb into withastro:main Nov 27, 2024
15 checks passed
@astrobot-houston astrobot-houston mentioned this pull request Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
3 participants