Yes afile is the file name and extension, ifile is the full file name and path.<div><br></div><div>Thanks</div><div>Vincent<span></span><br><br>On Sunday, October 14, 2012, MRAB  wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 2012-10-14 05:23, Vincent Davis wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I am working on a script to find bad image files. I am using PIL<br>
and specifically image.verify() I have a set of known to be bad image<br>
files to test. I also what to be able to test any file for example a<br>
.txt and deal with the exception.<br>
Currently my code is basically<br>
<br>
try:<br>
     im = Image.open(ifile)<br>
     try:<br>
         print(im.verify())<br>
     except:<br>
         print('Pil image.verify() failed: ' + afile)<br>
except IOError:<br>
     print('PIL cannot identify image file: ' + afile)<br>
except:<br>
     print(ifile)<br>
     print("Unexpected error doing PIL.Image.open():", sys.exc_info()[0])<br>
     raise<br>
<br>
</blockquote>
[snip]<br>
I notice that you have both "ifile" and "afile". Is that correct?<br>
<br>
-- <br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/<u></u>mailman/listinfo/python-list</a><br>
</blockquote></div><br><br>-- <br><div>Vincent Davis</div><div>720-301-3003<span></span><span></span></div><br>