Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

put cropped image in original image name folder python

filepath = '/some/file/path/Frames/'

for filename in os.listdir(filepath):
    if "." not in filename:
        continue
    ending = filename.split(".")[1]
    if ending not in ["jpg", "gif", "png"]:
        continue

    try:
        image = Image.open(os.path.join(filepath, filename))
    except IOError as e:
        print("Problem Opening", filepath, ":", e)
        continue

    image = image.crop((535, 40, 600, 90))

    name, extension = os.path.splitext(filename)
    print(name + '_cropped.jpg')
    image.save(os.path.join('/some/file/path/Frames/Cropped', name + '_cropped.jpg'))
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #put #cropped #image #original #image #folder #python
ADD COMMENT
Topic
Name
6+3 =