Python
code:python
import sys
import os
import glob
from PIL import Image, ImageChops
def main():
for image in glob.glob(args0 + '/*.jpg'): print(image)
imageProcess(image)
def imageProcess(file):
img = Image.open(file)
w, h = img.size
box = (w*0.05, 0, w*0.95, h)
img = img.crop(box)
bg = Image.new("RGB", img.size, img.getpixel((0, 0)))
diff = ImageChops.difference(img, bg)
croprange = diff.convert("RGB").getbbox()
crop_img = img.crop(croprange)
filename = os.path.basename(file)
if not os.path.isdir('output'):
os.mkdir("output")
crop_img.save("output/" + filename)
if __name__ == '__main__':
main()