diff --git a/README.md b/README.md index 37c6bd5..b43b7c2 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,21 @@ Because there's always more than one way to do it. + + +<"old skool" imagemagick docs ... https://imagemagick.org/Usage/> + +Flat - A Python library made to draw graphics but also designed to produce multi-paged PDFs +https://xxyxyz.org/ + +SILE - Typesetting software +http://sile-typesetter.org/ + +SILE - Typesetting software manual +http://sile-typesetter.org/images/sile-0.9.4.pdf + + + Links --------------- diff --git a/reportlab_image_poster.py b/reportlab_image_poster.py new file mode 100644 index 0000000..ef1f8cf --- /dev/null +++ b/reportlab_image_poster.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python3 + +import os, datetime, sys +from argparse import ArgumentParser +from glob import glob + +from PIL import Image +from reportlab.pdfgen import canvas +from reportlab.lib.pagesizes import A0 + + +# p = ArgumentParser("") +# p.add_argument("--output", default="poster.pdf") +# p.add_argument("--interpolation", default="cubic", help="nearest,cubic") +# p.add_argument("--labels", default="labels_public.txt") +# args = p.parse_args() + + +pagewidth, pageheight = A0 + +c = canvas.Canvas("reportlab_image_poster.pdf", pagesize=A0) +x, y = 0, 0 +imagewidth = 200 +aw = pagewidth - imagewidth +images = (glob ("images/*.JPG")) +dx = aw/(len(images)-1) +dy = 20 + +for image in images: + print ("Adding an image to the PDF") + print (image) + im = Image.open(image) + pxwidth, pxheight = im.size + print ("Got the image, it's size is:", im.size) + imageheight = imagewidth * (pxheight / pxwidth) + c.drawInlineImage(image, x, y, imagewidth, None) + print ("placing image {0} at {1}".format(image, (x,y))) + x += dx + y += dy + +c.showPage() +c.save() +sys.exit(0) + + +################# +# GRID +# imsize = 96 +# cols = int(A0[0] // imsize) +# rows = int(A0[1] // imsize) +# # calculate margins to center the grid on the page +# mx = (A0[0] - (cols*imsize)) / 2 +# my = (A0[1] - (rows*imsize)) / 2 +# print ("Grid size {0}x{1} (cols x rows)".format(cols, rows)) +# print (" (total size:", cols*imsize, rows*imsize, "margins:", mx, my, ")") +################# + +for l in range(7): + print (LABELS[l]) + col = 0 + row = 0 + with open(args.labels) as f: + f.readline() + for line in f: + path, label = line.split(",") + label = int(label) + if label == l: + image = Image.open(path) + print (image.size) + + x = mx + (col*imsize) + y = my + imsize + (7-l)*(4*imsize) - ((row+1)*imsize) + + c.drawInlineImage(image, x, y, width=imsize, height=imsize) + col += 1 + if col >= cols: + col = 0 + row +=1 + if row >= 3: + break + +c.showPage() +c.save() \ No newline at end of file