0

I have successfully sliced an individual image. Now I would like to have #this code to do every .jpg be sliced in a directory.

Here is my python code for slicing the individual images:

from PIL import Image
import os


image1=Image.open('banana.jpg')

import image_slicer
image_slicer.slice('banana.jpg', 60)

I have several images of fruit I would like to slice into smaller images #within this folder that are all the same size.

Alex
  • 1,172
  • 11
  • 31
ELW
  • 1
  • 3

1 Answers1

1

Use glob to get all jpgs from your current directory then slice them.

import glob, os
import image_slicer

os.chdir("./")
for file in glob.glob("*.jpg"):
    image_slicer.slice(file, 60)