image_slicer icon indicating copy to clipboard operation
image_slicer copied to clipboard

How can I apply this function to multiple images?

Open balaganeshmohan opened this issue 3 years ago • 2 comments

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

balaganeshmohan avatar Jul 12 '20 09:07 balaganeshmohan

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')

thinklikeanarchitect avatar Mar 21 '21 13:03 thinklikeanarchitect

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.

ritog avatar May 22 '21 10:05 ritog