import argparse import cv2 import numpy as np IN=25.4 DPI=600 MINLINE=150 def create_blank(width, height): rgb_color=(255,255,255) image = np.zeros((height, width, 3), np.uint8) color = tuple(reversed(rgb_color)) image[:] = color return image def guide (args) : if 'dpi' in args : DPI = args.dpi line = round(DPI/MINLINE) halfLine = round(line/2) if line == 1 : halfLine = 1 dims = args.dimensions.split('x') w = int(dims[0]) h = int(dims[1]) halfW = round(w/2) halfH = round(h/2) tenthW = round(w/10) tenthH = round(h/10) img = create_blank(w, h) print(line) print(w) print(h) # bisect cv2.line(img, (halfW, 0,), (halfW, h,), [0, 0, 0], line) cv2.line(img, (0, halfH,), (w, halfH,), [0, 0, 0], line) # outline cv2.line(img, (halfLine, 0,), (halfLine, h,), [0, 0, 0], line) cv2.line(img, (w-halfLine, 0,), (w-halfLine, h,), [0, 0, 0], line) cv2.line(img, (0, halfLine,), (w, halfLine,), [0, 0, 0], line) cv2.line(img, (0, h-halfLine,), (w, h-halfLine,), [0, 0, 0], line) # ticks for i in range(0, 9) : y1 = round(halfH + ((i + 1) * (tenthH/2))) y2 = round(halfH - ((i + 1) * (tenthH/2))) cv2.line(img, (halfW - round(tenthW/4), y1,), (halfW + round(tenthW/4), y1,), [0, 0, 0], line) cv2.line(img, (halfW - round(tenthW/4), y2,), (halfW + round(tenthW/4), y2,), [0, 0, 0], line) x1 = round(halfW + ((i + 1) * (tenthW/2))) x2 = round(halfW - ((i + 1) * (tenthW/2))) cv2.line(img, (x1, halfH - round(tenthH/4),), (x1, halfH + round(tenthH/4),), [0, 0, 0], line) cv2.line(img, (x2, halfH - round(tenthH/4),), (x2, halfH + round(tenthH/4),), [0, 0, 0], line) cv2.imwrite(args.output, img) def main () : parser = argparse.ArgumentParser() parser.add_argument('output', help='Output file') parser.add_argument('--dpi', '-d', help='DPI', required=False, type=int, default=600) parser.add_argument('--dimensions', '-D', help='Dimensions of image', required=True, type=str) args = parser.parse_args() guide(args) main()