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

When imghdr fails to deduce the image type, use file extension #807

Merged
merged 1 commit into from
Sep 11, 2020

Conversation

dismantl
Copy link
Member

Status

Ready for review

Description of Changes

I ran into what might be an edge case, where imghdr.what() failed to figure out the filetype of a submitted photo. So I added in this little snippet in case imghdr fails, to determine image type using the filename.

I'm not really sure what a good way to add tests for this is, since I don't really know why imghdr failed for this particular image. For reference, the image was https://bpdwatch.s3.amazonaws.com/8d/095b8184d1d4abd90e867a8b2d41961bcc4fbd2b42e2af6f0ad8c80ca44fc7.jpg

Notes for Deployment

Screenshots (if appropriate)

Tests and linting

  • I have rebased my changes on current develop

  • pytests pass in the development environment on my local machine

  • flake8 checks pass

Copy link
Member

@redshiftzero redshiftzero left a comment

Choose a reason for hiding this comment

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

just checked the extensions here, lgtm

I think we could add test coverage with some test files for each extension but this is good to merge as is

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