Advertisement
here2share

# t_webp2jpg_plus.py

Jan 18th, 2021
1,160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. # t_webp2jpg_plus.py
  2.  
  3. from tkFileDialog import askdirectory
  4. folder = askdirectory() # needs to be placed after pack()
  5. import os
  6. from PIL import Image
  7.  
  8. filenames = os.listdir(folder)
  9. print(folder)
  10. print
  11. extensions = '.jpg .jpeg .png'.split()
  12.  
  13. for file in filenames:
  14.     f = folder+'/'+file
  15.     if file.endswith('.webp'):
  16.         print('***\t\t'+file)
  17.         f = folder+'/'+file
  18.         img = Image.open(f).convert('RGB')
  19.         img.save(f.rsplit('.',1)[0]+'.jpg', 'jpeg')
  20.     elif file.endswith('.jpg_large'):
  21.         print('***\t\t'+file)
  22.         os.rename(f,f.rsplit('.jpg',1)[0]+'.jpg')
  23.     elif file.endswith('.jpeg_large'):
  24.         print('***\t\t'+file)
  25.         os.rename(f,f.rsplit('.jepg',1)[0]+'.jpg')
  26.     else:
  27.         print(f)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement