Skip to content

model: tolerate truncated JPEG files#10

Merged
github-actions[bot] merged 1 commit intomainfrom
truncated-jpeg
Mar 25, 2026
Merged

model: tolerate truncated JPEG files#10
github-actions[bot] merged 1 commit intomainfrom
truncated-jpeg

Conversation

@kdudka
Copy link
Copy Markdown
Owner

@kdudka kdudka commented Mar 24, 2026

... to avoid OSError: broken data stream when reading image file

Related: #9
PR: #10

Summary by Sourcery

Bug Fixes:

  • Prevent image loading from raising errors on truncated JPEG files by tolerating broken data streams during processing.

@kdudka kdudka requested a review from iswiac March 24, 2026 08:55
@kdudka kdudka self-assigned this Mar 24, 2026
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Mar 24, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts the image loading logic in pdx/model.py so that truncated JPEG files are tolerated instead of raising an OSError when read.

File-Level Changes

Change Details Files
Update image-loading behavior to tolerate truncated JPEG files instead of failing with OSError.
  • Modify image decoding configuration to allow loading of truncated JPEGs (likely via PIL/ImageFile settings or equivalent).
  • Ensure that model image-processing workflows continue even when encountering incomplete JPEG data.
  • Centralize the tolerance behavior in the existing model image-loading path so callers do not need to change their usage.
pdx/model.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

... to avoid `OSError: broken data stream when reading image file`

Related: #9
PR: #10
Copy link
Copy Markdown
Collaborator

@iswiac iswiac left a comment

Choose a reason for hiding this comment

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

Works like a charm ! tested several panoramatic photos up to 26080 x 2032 and 54MB size jpg.

Regress tested also indexing speed and seems to be even faster. e.g indexed 9700+ photos locally took 4 minutes.

Thank you

@kdudka
Copy link
Copy Markdown
Owner Author

kdudka commented Mar 25, 2026

Perfect, thank you for testing it!

@kdudka
Copy link
Copy Markdown
Owner Author

kdudka commented Mar 25, 2026

/fast-forward

@github-actions
Copy link
Copy Markdown

Successfully fast-forwarded! 🚀

@github-actions github-actions bot merged commit da37de7 into main Mar 25, 2026
3 checks passed
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