Skip to content
Snippets Groups Projects
png_format.py 280 B
Newer Older
  • Learn to ignore specific revisions
  • from PIL import Image
    
    Jesper Zedlitz's avatar
    Jesper Zedlitz committed
    
    
    def is_valid(resource, file):
        """Check if the content is a readable PNG image."""
    
        try:
            with Image.open(file.name, formats=["PNG"]):
                return True
    
        except Exception as e:
            resource["error"] = str(e)
    
    Jesper Zedlitz's avatar
    Jesper Zedlitz committed
            return False