Commit 7c9f23ef by murtaugh

second poster

parent 5d1364ec
......@@ -44,7 +44,7 @@ sampleimages: sample.csv
sample.json: sample.csv scripts/csv2json.py
scripts/csv2json.py $< > $@
poster.pdf: sample.json scripts/orderings.poster.py
poster.pdf: sample_with_data.json scripts/orderings.poster.py
scripts/orderings.poster.py $< --output $@
sample/exif.json:
......
......@@ -116,8 +116,31 @@ canvas.setStrokeColorRGB(0.0,0.0,0.0)
canvas.setFont('LabelFont', args.fontsize)
print ("{0} items".format(len(data)), file=sys.stderr)
def drawImageBox (ipath, x, c, r, boxsize=100, drawBorder=False):
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
dx, dy = (ccw - imw) / 2, (cch - imh) / 2
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
)
if drawBorder:
canvas.rect(cx, cy, cellwidth, cellheight)
return cx, cy, dx, dy
r = 0
for sortkey in "name inventory image_filesize dimensions dating".split():
for sortkey in "name inventory image_filesize dimensions dating red green blue contours gradient".split():
# SORT
data.sort(key=lambda x: value(x[sortkey]))
print ("[{0}] range from {1} to {2}".format(sortkey, label(data[0][sortkey]), label(data[-1][sortkey])))
......@@ -135,28 +158,38 @@ for sortkey in "name inventory image_filesize dimensions dating".split():
for gi, group in enumerate(groups):
c= 0
for i in group:
ipath = os.path.join(args.imagespath, i['img'])
im = Image.open(ipath)
im.thumbnail((100, 100), Image.ANTIALIAS)
imw = (im.size[0]/100) * ccw
imh = (im.size[1]/100) * cch
# centering dx,dy
dx, dy = (ccw - imw) / 2, (cch - imh) / 2
cx = groupx + (c*cellwidth)
cy = pageheight - pagemargin['top'] - ((r+1+1)*cellheight)
# DRAW IMAGE
canvas.drawImage(ImageReader(im), cx+dx+cellmargin['left'], cy+dy+cellmargin['bottom'], width=imw, height=imh)
ipath = i['img']
drawImageBox(ipath, groupx, c, r+1)
# im = Image.open(ipath)
# im.thumbnail((100, 100), Image.ANTIALIAS)
# imw = (im.size[0]/100) * ccw
# imh = (im.size[1]/100) * cch
# # centering dx,dy
# dx, dy = (ccw - imw) / 2, (cch - imh) / 2
# cx = groupx + (c*cellwidth)
# cy = pageheight - pagemargin['top'] - ((r+1+1)*cellheight)
# # DRAW IMAGE
# canvas.drawImage(ImageReader(im), cx+dx+cellmargin['left'], cy+dy+cellmargin['bottom'], width=imw, height=imh)
# canvas.rect(cx, cy, cellwidth, cellheight)
# DRAW DATA BOX
cy = pageheight - pagemargin['top'] - ((r+1)*cellheight)
if fillDataBox:
canvas.setFillColorRGB(*boxfill)
canvas.rect(cx+dx+cellmargin['left'], cy+dy+cellmargin['bottom'], imw, imh, stroke=0, fill=1)
# cy = pageheight - pagemargin['top'] - ((r+1)*cellheight)
if 'img' in i[sortkey]:
drawImageBox(i[sortkey]['img'], groupx, c, r)
# add a fill option
# if fillDataBox:
# canvas.setFillColorRGB(*boxfill)
# canvas.rect(cx+dx+cellmargin['left'], cy+dy+cellmargin['bottom'], imw, imh, stroke=0, fill=1)
# drawTextCenteredInBox
# txt = i['FileModifyDate_parsed'].strftime("%Y-%m-%d %H:%M:%S")
txt = label(i[sortkey])
canvas.setFillColorRGB(*textcolor)
canvas.drawCentredString(cx+dx+cellmargin['left']+(imw/2), cy+dy+cellmargin['bottom']+(imh/2), "{0}".format(txt))
if txt:
cx = groupx + (c*cellwidth)
cy = pageheight - pagemargin['top'] - ((r+1)*cellheight)
canvas.setFillColorRGB(*textcolor)
# canvas.drawCentredString(cx+dx+cellmargin['left']+(imw/2), cy+dy+cellmargin['bottom']+(imh/2), "{0}".format(txt))
canvas.drawCentredString(cx+(cellwidth/2), cy+(cellheight/2), "{0}".format(txt))
# print("cx, cy", cx, cy, file=sys.stderr)
c += 1
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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