|
@@ -3,7 +3,7 @@
|
|
|
import sys
|
|
|
import os
|
|
|
|
|
|
-from PIL import Image
|
|
|
+from PIL import Image, ImageFont, ImageDraw
|
|
|
from math import log2, pow
|
|
|
|
|
|
from flask import Flask, send_from_directory
|
|
@@ -18,21 +18,34 @@ def crop(k, dir, im, x, y, sx, sy):
|
|
|
if (k == 0):
|
|
|
return
|
|
|
|
|
|
+ font = ImageFont.truetype("JackInput.ttf", 50)
|
|
|
os.makedirs(dir, exist_ok=True)
|
|
|
q1 = im.crop((0, 0, x/2, y/2))
|
|
|
- q1.resize((sx, sy), Image.LANCZOS).save(dir + (dir.replace('/', '')[2:]) + "00.jpg", "JPEG")
|
|
|
+ rq1 = q1.resize((sx, sy), Image.LANCZOS)
|
|
|
+ dq1 = ImageDraw.Draw(rq1)
|
|
|
+ dq1.text((0, 0), str(int((dir.replace('/', '')[2:]) + "00", 2)), (255, 0, 0), font=font)
|
|
|
+ rq1.save(dir + (dir.replace('/', '')[2:]) + "00.jpg", "JPEG")
|
|
|
|
|
|
os.makedirs(dir, exist_ok=True)
|
|
|
q2 = im.crop((x/2, 0, x, y/2))
|
|
|
- q2.resize((sx, sy), Image.LANCZOS).save(dir + (dir.replace('/', '')[2:]) + "01.jpg", "JPEG")
|
|
|
+ rq2 = q2.resize((sx, sy), Image.LANCZOS)
|
|
|
+ dq2 = ImageDraw.Draw(rq2)
|
|
|
+ dq2.text((0, 0), str(int((dir.replace('/', '')[2:]) + "01", 2)), (255, 0, 0), font=font)
|
|
|
+ rq2.save(dir + (dir.replace('/', '')[2:]) + "01.jpg", "JPEG")
|
|
|
|
|
|
os.makedirs(dir, exist_ok=True)
|
|
|
q3 = im.crop((0, y/2, x/2, y))
|
|
|
- q3.resize((sx, sy), Image.LANCZOS).save(dir + (dir.replace('/', '')[2:]) + "10.jpg", "JPEG")
|
|
|
+ rq3 = q3.resize((sx, sy), Image.LANCZOS)
|
|
|
+ dq3 = ImageDraw.Draw(rq3)
|
|
|
+ dq3.text((0, 0), str(int((dir.replace('/', '')[2:]) + "10", 2)), (255, 0, 0), font=font)
|
|
|
+ rq3.save(dir + (dir.replace('/', '')[2:]) + "10.jpg", "JPEG")
|
|
|
|
|
|
os.makedirs(dir, exist_ok=True)
|
|
|
q4 = im.crop((x/2, y/2, x, y))
|
|
|
- q4.resize((sx, sy), Image.LANCZOS).save(dir + (dir.replace('/', '')[2:]) + "11.jpg", "JPEG")
|
|
|
+ rq4 = q4.resize((sx, sy), Image.LANCZOS)
|
|
|
+ dq4 = ImageDraw.Draw(rq4)
|
|
|
+ dq4.text((0, 0), str(int((dir.replace('/', '')[2:]) + "11", 2)), (255, 0, 0), font=font)
|
|
|
+ rq4.save(dir + (dir.replace('/', '')[2:]) + "11.jpg", "JPEG")
|
|
|
|
|
|
crop(k-1, dir + "00/", q1, q1.width, q1.height, sx, sy)
|
|
|
crop(k-1, dir + "01/", q2, q2.width, q2.height, sx, sy)
|