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

checking file type with PIL #1173

Merged
merged 1 commit into from
Apr 7, 2024

Conversation

serengil
Copy link
Owner

@serengil serengil commented Apr 7, 2024

imghdr is deprecated

Tickets

#1169

What has been done

With this PR, file type check is done with PIL because imghdr is deprecated.

How to test

make lint && make test

imghdr is deprecated
@serengil serengil merged commit ba4d193 into master Apr 7, 2024
4 checks passed
@serengil serengil deleted the feat-task-0704-find-image-type-with-pil branch April 7, 2024 09:12
Comment on lines +308 to 312
img = Image.open(exact_path) # lazy

file_type = img.format.lower()
if file_type in ["jpeg", "png"]:
images.append(exact_path)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
img = Image.open(exact_path) # lazy
file_type = img.format.lower()
if file_type in ["jpeg", "png"]:
images.append(exact_path)
with Image.open(exact_path) as img:
if img.format.lower() in ["jpeg", "png"]:
images.append(exact_path)

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