Skip to content

Support more jpeg SOF markers for size reading the dimensions correctly#49

Merged
michal-lightly merged 3 commits intomainfrom
support-more-markers-for-size-reading-is
Dec 2, 2025
Merged

Support more jpeg SOF markers for size reading the dimensions correctly#49
michal-lightly merged 3 commits intomainfrom
support-more-markers-for-size-reading-is

Conversation

@IgorSusmelj
Copy link
Copy Markdown
Contributor

Changes

  • Fixed a bug in jpg dimension parsing. In get_jpeg_dimensions(...) we try to only read the first few bytes to obtain the correct width and height of a jpeg image. This failed for certain files as we treated a DHT table start as a marker which resulted in some non sense dimensions.
  • We now have an explicit list of jpg SOF (start of frame) markers that we check for. If the given jpg file does not any of them we move on and use pillow to properly decode the image and then get the dimension.
  • We added more unit tests to catch the issue.

Comment thread src/labelformat/utils.py Outdated
Comment thread tests/unit/test_utils.py Outdated
Comment thread tests/unit/test_utils.py
Comment thread tests/unit/test_utils.py
@michal-lightly michal-lightly merged commit b7b3612 into main Dec 2, 2025
2 checks passed
@michal-lightly michal-lightly deleted the support-more-markers-for-size-reading-is branch December 2, 2025 09:26
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.

2 participants