Skip to content
Snippets Groups Projects
Select Git revision
  • a1b993f17477f7addb07f8f05bc0b4c74fae6553
  • main default protected
  • ci_test
  • v2.0.27 protected
  • v2.0.26 protected
  • v2.0.25 protected
  • v2.0.24 protected
  • v2.0.23 protected
  • v2.0.22 protected
  • v2.0.21 protected
  • v2.0.20 protected
  • v2.0.19 protected
  • v2.0.18 protected
  • v2.0.17 protected
  • v2.0.16 protected
  • v2.0.15 protected
  • v2.0.14 protected
  • v2.0.13 protected
  • v2.0.12 protected
  • v2.0.11 protected
  • v2.0.10 protected
  • v2.0.9 protected
  • v2.0.8 protected
23 results

object_modifications.py

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    intro 1.63 KiB
    #!/usr/bin/env python3
    from util import ping_job, getcurjobid, getjobdata, buildpath, job_failed
    from PIL import Image, ImageFont, ImageDraw
    import traceback
    import sys
    import json
    import os
    
    def centerText(img, draw, fnt, top, msg, color='white'):
    	iw, ih = img.width, img.height
    	tw, th = draw.textsize(msg, font=fnt)
    	draw.text(((iw-tw)/2, top), msg, font=fnt, fill=color)
    
    def main():
    	if not len(sys.argv) == 5:
    		exit(1)
    	data = getjobdata()
    	outputfile = buildpath(os.environ.get('WORKER_RAW'), data['path']);
    	data = data['metadata']
    	with Image.new("RGB",(1920,1080),"black") as img:
    		fontpath = 'assets/LiberationSans-Regular.ttf'
    		draw = ImageDraw.Draw(img)
    		fnt = ImageFont.truetype(fontpath, 92)
    		centerText(img, draw, fnt, 270, data.get('album', ''))
    		fnt = ImageFont.truetype(fontpath, 69)
    		centerText(img, draw, fnt, 500, data.get('artist', ''))
    		fnt = ImageFont.truetype(fontpath, 72)
    		centerText(img, draw, fnt, 710, '{} vom {}'.format(data.get('title', ''), data.get('date', '').replace('/', '.')))
    		fnt = ImageFont.truetype(fontpath, 36)
    		centerText(img, draw, fnt, 910, 'Video erstellt von der Video AG der Fachschaft I/1')
    		linkblue = (81, 122, 231)
    		fnt = ImageFont.truetype(fontpath, 38)
    		centerText(img, draw, fnt, 950, 'https://video.rwth-aachen.de/', color=linkblue)
    		centerText(img, draw, fnt, 990, 'video@fsmpi.rwth-aachen.de', color=linkblue)
    		with Image.open('assets/lgog_embed2.png') as logo:
    			img.paste(logo,(1722, 924))
    		img.save(outputfile, "PNG")
    	ping_job('finished')
    	exit(0)
    
    if __name__ == '__main__':
    	try:
    		main()
    	except Exception as e:
    		try:
    			job_failed(str(e))
    		except:
    			traceback.print_exc()
    			exit(3)