Created
January 17, 2019 10:26
-
-
Save AnBucquet/f61e1b5feb6fd8f5202cb1eb365146d1 to your computer and use it in GitHub Desktop.
A little function to split an image into many and save them into a specific directory.
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
| from PIL import Image | |
| def split(path, input, height, width): | |
| im = Image.open(input) | |
| k = 0 | |
| imgwidth, imgheight = im.size | |
| for i in range(0,imgheight,height): | |
| for j in range(0,imgwidth,width): | |
| box = (j, i, j+width, i+height) | |
| a = im.crop(box) | |
| try: | |
| a.save(path+"VanGogh_fake_{}".format(k)+'.jpg') | |
| except: | |
| pass | |
| k +=1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment