Skip to content

Instantly share code, notes, and snippets.

@shin-
Last active November 16, 2018 00:54
Show Gist options
  • Save shin-/92fc9f6226ac1a1b52aa92cc0a0d7a6e to your computer and use it in GitHub Desktop.
Save shin-/92fc9f6226ac1a1b52aa92cc0a0d7a6e to your computer and use it in GitHub Desktop.
# 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