Created
May 21, 2013 01:21
-
-
Save nakagami/5616920 to your computer and use it in GitHub Desktop.
Walk and detect CMYK Jpeg, and print it's path name
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
#!/usr/bin/env python | |
""" | |
Detect CMYK Jpeg under current directory | |
use PIL (or Pillow) | |
""" | |
import os | |
from PIL import Image | |
START_PATH='.' | |
for (path, dirs, files) in os.walk(START_PATH): | |
for f in files: | |
_, ext = os.path.splitext(f) | |
if ext == '.jpg' or ext == '.jpeg': | |
p = os.path.join(path, f) | |
try: | |
image = Image.open(p) | |
if image.mode == 'CMYK': | |
print('CMYK', p) | |
except IOError as e: | |
print(e, p) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment