About Checking if a File is an Image
You can check if a file is an image with this function:
1 2 3 4 5 6 7 | def is_image(file_path): from PIL import Image try: Image.open(file_path).verify() except IOError: return False return True |
Also by me
Django Paddle Subscriptions app
For Django-based SaaS projects.
Django App for You
Django GDPR Cookie Consent app
For Django websites that use cookies.
Django App for You