def is_valid_image(self, raw_data):
        '''
        Wand library makes sure when opening any image that is fine, when
        the image is corrupted raises an exception.
        '''

        try:
            Image(blob=raw_data)
            return True
        except (exceptions.CorruptImageError, exceptions.MissingDelegateError):
            return False
def is_valid_image ( self , raw_data ) : try : Image ( blob = raw_data ) return True except ( exceptions . CorruptImageError , exceptions . MissingDelegateError ) : return False
Wand library makes sure when opening any image that is fine, when
        the image is corrupted raises an exception.