statfile = os.stat(filename) filesize = statfile.st_size if filesize == 0: #manage here the 'faulty image' case