Python
專案架構
前後端分離
工具
套件管理器、建置工具
pyproject.toml
ruff
程式碼格式化
ty
型別檢查
pytest
測試
Pydantic
資料驗證
MkDocs
專案文件、靜態網站
Dataclasses
版本控制
GitHub Actions
Dependabot
Gitleaks
pre-commit
基礎建設管理
Make
Docker
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()