samdobson / image_slicer

Split images into tiles. Join the tiles back together.
http://samdobson.github.io/image_slicer
MIT License
151 stars 73 forks source link

How can I apply this function to multiple images? #39

Open balaganeshmohan opened 4 years ago

balaganeshmohan commented 4 years ago

I have a list of 300 or so images, that needs to be split into 4. I wasn't successful to iterate over that list and apply image_slicer. Anyone can help me. Thanks

thinklikeanarchitect commented 3 years ago

You need to create a directory named 'slices' at the same directory where the code below will work.


import glob, os
import image_slicer

os.chdir("./")
for file in glob.glob("*.png"):
    image_slicer.slice(file, 4, save=False)
    image_slicer.save_tiles(tiles, directory='./slices',\
                            prefix=file, format='png')
ritog commented 3 years ago

I used a for loop. Worked fine.

Listed all files in the directory using os.listdir() method, and then iterated through the loop.

I had about 12,000 high-res images. It took about 4-5 hours.