Last active
November 16, 2018 00:54
-
-
Save shin-/92fc9f6226ac1a1b52aa92cc0a0d7a6e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip3 install exifread && python3 nonsquares.py ~/Pictures | xargs rm -f | |
import os | |
import sys | |
import exifread | |
def main(basedir): | |
for dirpath, _, filenames in os.walk(basedir): | |
for name in filenames: | |
if not name.endswith('.jpg'): | |
continue | |
filename = os.path.join(dirpath, name) | |
with open(filename, 'rb') as f: | |
tags = exifread.process_file(f) | |
if 'EXIF ExifImageLength' not in tags: | |
print('No EXIF data for {}'.format(filename), file=sys.stderr) | |
continue | |
if tags['EXIF ExifImageLength'] != tags['EXIF ExifImageWidth']: | |
print(filename) | |
if __name__ == '__main__': | |
main(sys.argv[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment