Skip to content

Commit

Permalink
$CODE : bugfix check_jpegs skipped .JPG and .JPEG files (uppercase fi…
Browse files Browse the repository at this point in the history
…lename)

$DOC : more precise description of corruption detection
  • Loading branch information
albion2000 committed Jan 14, 2018
1 parent e82163f commit 5281ce7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
21 changes: 11 additions & 10 deletions tools/check_jpegs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
from PIL import Image
import sys


# this code also should work for other compressions, with little changes

def isJpeg(fname):
if (fname.lower().find(".jpg") == len(fname)-4) :
return True
if (fname.lower().find(".jpeg") == len(fname)-4) :
return True
return False

def process(fullCheck):

# Set the directory you want to start from
Expand All @@ -28,16 +38,7 @@ def process(fullCheck):
currentPath = os.getcwd();
for fname in fileList:
# print('\t%s' % fname)

thisisajpeg = 0
# this code also should work for other compressions
extposjpg = fname.find(".jpg")
if (extposjpg == len(fname)-4) :
thisisajpeg = 1
extposjpg = fname.find(".jpeg")
if (extposjpg == len(fname)-4) :
thisisajpeg = 1
if (thisisajpeg==1):
if (isJpeg(fname)):
found = 1;
allJPGFilesCount = allJPGFilesCount+1
newTuple = (dirName+'/'+fname,);
Expand Down
6 changes: 3 additions & 3 deletions tools/readme_check_jpegs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ ACTION
USE
* Copy 'check_jpegs.py' & 'check_jpegs_full.py' to the root directory of your file three.
* either Double click on the file 'check_jpegs.py' for a quick sanity check. It is, on purpose, a fast check in order to help detect rapidly bad files. Only the headers are checked, the images are not decompressed.
* or Double click on the file 'check_jpegs_full.py' instead for a full sanity check
* or Double click on the file 'check_jpegs_full.py' instead for a much deeper sanity check

NOTES
* Each '.' shows that one more directory was parsed
* When a file is reported as corrupted, it does not mean that it is lost. Try to open it in your favorite image sw and save it back (using the best quality, in order to reduce compression losses). It is often enough. If you can't open it, try to open it with other image tools. Not all handle file corruption the same way.

* Does not detect all types of file corruption. Some corruptions that do not prevent image display won't be detected.

==============================================================================

Expand All @@ -43,4 +43,4 @@ USAGE
NOTES
* Chaque '.' indique d'un r�pertoire suppl�mentaire a �t� trait�
* Quoi faire avec le r�sultat du "check" ? Fichier corrompu ? Ne signifie pas qu'il est perdu. Essayez de le charger avec tous vos logiciels capables de charger et sauvegarder des jpeg (� la meilleure qualit� pour r�duire les alt�rations dues � la compression). Cela suffit souvent pour r�cup�rer le fichier.

* Ne d�tectera pas absolument tous les types de corruption, mais au moins ceux qui empecheraient la visualisation de l'image. Et certains de ceux qui abiment l'image.

0 comments on commit 5281ce7

Please sign in to comment.