Gitlab will be down on Friday 25th May (from 9:00 am to 12:00 )

Commit c45e211a by murtaugh

allow missing images in poster

parent 78faeb72
......@@ -76,15 +76,6 @@ args = ap.parse_args()
pagesize = getattr(reportlab.lib.pagesizes, args.pagesize)
# # datetime
# # parsed_date = datetime.datetime.strptime( mydate, "%Y:%m:%d %H:%M:%S" )
# def parsedate (d):
# # 2010:11:25 17:33:12+01:00
# # map +01:00 to +0100 which strptime can grok as %z
# d = re.sub(r"\+(\d\d):(\d\d)$", r"+\1\2", d)
# return datetime.datetime.strptime(d, "%Y:%m:%d %H:%M:%S%z")
# DATA
with open (args.data) as f:
data = json.load(f)
......@@ -133,33 +124,37 @@ print ("{0} items".format(len(data)), file=sys.stderr)
def drawImageBox (ipath, x, c, r, boxsize=100, drawBorder=False, valign="center"):
im = Image.open(ipath)
# boxsize sets the resolution of the image such that it fits in boxsize x boxsize pixels
im.thumbnail((boxsize, boxsize), Image.ANTIALIAS)
imw = (im.size[0]/boxsize) * ccw
imh = (im.size[1]/boxsize) * cch
# centering dx,dy
if valign=="top":
dx, dy = (ccw - imw) / 2, (cch - imh)
elif valign=="center":
dx, dy = (ccw - imw) / 2, (cch - imh) / 2
else: # "bottom"
dx, dy = (ccw - imw) / 2, 0
cx = x + (c*cellwidth)
cy = pageheight - pagemargin['top'] - ((r+1)*cellheight)
# DRAW IMAGE
canvas.drawImage(
ImageReader(im),
cx+dx+cellmargin['left'],
cy+dy+cellmargin['bottom'],
width=imw,
height=imh,
mask='auto' # https://stackoverflow.com/questions/1308710/transparency-in-pngs-with-reportlab-2-3#1625350
)
if drawBorder:
canvas.rect(cx, cy, cellwidth, cellheight)
return cx, cy, dx, dy, imw, imh
try:
im = Image.open(ipath)
# boxsize sets the resolution of the image such that it fits in boxsize x boxsize pixels
im.thumbnail((boxsize, boxsize), Image.ANTIALIAS)
imw = (im.size[0]/boxsize) * ccw
imh = (im.size[1]/boxsize) * cch
# centering dx,dy
if valign=="top":
dx, dy = (ccw - imw) / 2, (cch - imh)
elif valign=="center":
dx, dy = (ccw - imw) / 2, (cch - imh) / 2
else: # "bottom"
dx, dy = (ccw - imw) / 2, 0
# DRAW IMAGE
canvas.drawImage(
ImageReader(im),
cx+dx+cellmargin['left'],
cy+dy+cellmargin['bottom'],
width=imw,
height=imh,
mask='auto' # https://stackoverflow.com/questions/1308710/transparency-in-pngs-with-reportlab-2-3#1625350
)
if drawBorder:
canvas.rect(cx, cy, cellwidth, cellheight)
return cx, cy, dx, dy, imw, imh
except Exception as e:
print ("Exception {0}".format(e))
return cx, cy, 0, 0, cellwidth, cellheight
r = 0
for sortkey in "name inventory image_filesize dimensions dating red green blue contours gradient tex lex".split():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment