Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Troubleshoot Sharp corrupted image loading issue #65

Closed
nathanielrindlaub opened this issue Sep 5, 2023 · 1 comment
Closed

Troubleshoot Sharp corrupted image loading issue #65

nathanielrindlaub opened this issue Sep 5, 2023 · 1 comment
Assignees

Comments

@nathanielrindlaub
Copy link
Member

Related to #60.

Sharp fails to load and resize images that are corrupted (errors look like VipsJpeg: Corrupt JPEG data: 18 extraneous bytes before marker 0xd2) - which happens a lot with wireless cameras. Typically it's just a pixel or two that is missing so the images still have a lot of information and value, and a lot of other photo apps have no problem opening them.

It looks like Sharp has a setting to relax when it fails (see options.failOn here). Look into this and experiment.

@nathanielrindlaub nathanielrindlaub self-assigned this Sep 5, 2023
@nathanielrindlaub
Copy link
Member Author

nathanielrindlaub commented Sep 5, 2023

Options to pass to failOn, copied from from Sharp docs:

when to abort processing of invalid pixel data, one of (in order of sensitivity): 'none' (least), 'truncated', 'error' or 'warning' (most), higher levels imply lower levels, invalid metadata will always abort.

e.g.:

// play around with 'none', 'truncated', etc. with various different corrupted images we've encountered to see what happens
await sharp(path.join(this.tmp_dir, md.FileName), { failOn: 'none' })
            .resize(dims[0], dims[1], {
                fit: 'inside'
            })
            .toFile(tmp_path);

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant