Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # img_remove_hidden_data.py
- from PIL import Image
- import re, os, sys
- import shutil
- fromDir=r"C:\Users\here2share\New Images"
- def pf(*z): return '\\'.join(z)
- toDir=pf(fromDir,"Removed Hidden")
- if not os.path.exists(toDir): os.makedirs(toDir)
- def cleanup_image(f):
- if f.lower().endswith(tuple('.png .bmp .jpg .jpeg'.split())):
- try:
- img = Image.open(pf(fromDir, f))
- img.save(pf(toDir, os.path.splitext(f)[0]+'.jpg'))
- print '#',
- except:
- shutil.copy(pf(fromDir, f), pf(toDir, r'000 '+f))
- print '>',
- for f in os.listdir(fromDir): cleanup_image(f)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement