Last active
          June 18, 2018 13:11 
        
      - 
      
 - 
        
Save kndt84/fa7eb9bcd44abec2832a18547db8e3d6 to your computer and use it in GitHub Desktop.  
  
    
      This file contains hidden or 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
    
  
  
    
  | import os | |
| import glob | |
| from PIL import Image, ImageOps | |
| path_list = glob.glob('*.png') | |
| for path in path_list: | |
| filename, ext = os.path.splitext( os.path.basename(path) ) | |
| im = Image.open(path) | |
| width, height = im.size | |
| x1= (width-height)/2 | |
| y1=0 | |
| x2=(width-height)/2+height | |
| y2=height | |
| im2 = im.crop((x1,y1,x2,y2)).resize((256,256)) | |
| im2.save('%s-crop%s' % (filename, ext)) | |
| im2.rotate(90).save('%s-r90%s' % (filename, ext)) | |
| im2.rotate(180).save('%s-r180%s' % (filename, ext)) | |
| im2.rotate(270).save('%s-r270%s' % (filename, ext)) | |
| ImageOps.flip(im2).save('%s-flip%s' % (filename, ext)) | |
| ImageOps.mirror(im2).save('%s-mirror%s' % (filename, ext)) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment