update arsenalberlin poster script; some cosmetic changes

This commit is contained in:
rolux 2013-06-06 18:49:48 +02:00
parent d8dd1bde5a
commit a53d41d1af
3 changed files with 35 additions and 15 deletions

View file

@ -23,9 +23,9 @@ static_root = os.path.join(os.path.dirname(__file__), 'data')
def render_poster(data, poster): def render_poster(data, poster):
title = ox.decode_html(data.get('title', '')) title = ox.decode_html(data.get('title', ''))
director = u', '.join(data.get('director', [])) director = ox.decode_html(u', '.join(data.get('director', [])))
director = ox.decode_html(director)
year = str(data.get('year', '')) year = str(data.get('year', ''))
version = data.get('version')
frame = data.get('frame') frame = data.get('frame')
timeline = data.get('timeline') timeline = data.get('timeline')
@ -39,8 +39,8 @@ def render_poster(data, poster):
poster_image = Image.new('RGB', (poster_width, poster_height)) poster_image = Image.new('RGB', (poster_width, poster_height))
draw = ImageDraw.Draw(poster_image) draw = ImageDraw.Draw(poster_image)
font_file = os.path.join(static_root, 'SourceSansProSemibold.ttf') font_file = os.path.join(static_root, 'SourceSansProSemibold.ttf')
font_size = {'arsenal': 120, 'director': 32, 'title': 48, 'year': 426} font_size = {'arsenal': 120, 'director': 32, 'title': 48, 'version': 24, 'year': 426}
font_lightness = {'arsenal': 0.7, 'director': 0.8, 'title': 0.8, 'year': 0.6} font_lightness = {'arsenal': 0.7, 'director': 0.8, 'title': 0.8, 'version': 0.8, 'year': 0.6}
poster_lightness = {'image': 0.2, 'text': 0.4} poster_lightness = {'image': 0.2, 'text': 0.4}
if year: if year:
@ -73,7 +73,7 @@ def render_poster(data, poster):
drawText( drawText(
poster_image, poster_image,
(-9 + x, poster_height - timeline_height - font_size['arsenal'] + 1 + y), (-9 + x, poster_height - timeline_height - font_size['arsenal'] + 1 + y),
'Indiancine.ma', 'arsenalberl.in',
font_file, font_file,
font_size['arsenal'], font_size['arsenal'],
getRGB((hue, saturation, poster_lightness['text'])) getRGB((hue, saturation, poster_lightness['text']))
@ -81,16 +81,16 @@ def render_poster(data, poster):
drawText( drawText(
poster_image, poster_image,
(-9, poster_height - timeline_height - font_size['arsenal'] + 1), (-9, poster_height - timeline_height - font_size['arsenal'] + 1),
'Indiancine.ma', 'arsenalberl.in',
font_file, font_file,
font_size['arsenal'], font_size['arsenal'],
getRGB((hue, saturation, font_lightness['arsenal'])) getRGB((hue, saturation, font_lightness['arsenal']))
) )
# director and title # text
offset_top = frame_height + text_margin offset_top = frame_height + text_margin
if not director: if not director:
title_max_lines = 8 title_max_lines = 7
else: else:
title_max_lines = min(len(wrapText( title_max_lines = min(len(wrapText(
title, title,
@ -98,8 +98,8 @@ def render_poster(data, poster):
0, 0,
font_file, font_file,
font_size['title'] font_size['title']
)), 7) )), 6)
director_max_lines = 11 - int((title_max_lines * 3 - 1) / 2) director_max_lines = 10 - int((title_max_lines * 3 - 1) / 2)
# director # director
if director: if director:
@ -151,7 +151,7 @@ def render_poster(data, poster):
font_size['title'], font_size['title'],
getRGB((hue, saturation, poster_lightness['text'])) getRGB((hue, saturation, poster_lightness['text']))
) )
drawText( size = drawText(
poster_image, poster_image,
(text_margin, offset_top), (text_margin, offset_top),
line, line,
@ -160,6 +160,28 @@ def render_poster(data, poster):
getRGB((hue, saturation, font_lightness['title'])) getRGB((hue, saturation, font_lightness['title']))
) )
offset_top += font_size['title'] + 3 offset_top += font_size['title'] + 3
offset_top += size[1] - font_size['title'] + 3
# version
if version:
for y in [-1, 1]:
for x in [-1, 1]:
drawText(
poster_image,
(text_margin + x, offset_top + y),
version,
font_file,
font_size['version'],
getRGB((hue, saturation, poster_lightness['text']))
)
size = drawText(
poster_image,
(text_margin, offset_top),
version,
font_file,
font_size['version'],
getRGB((hue, saturation, font_lightness['title']))
)
# frame # frame
if frame: if frame:

View file

@ -23,8 +23,7 @@ static_root = os.path.join(os.path.dirname(__file__), 'data')
def render_poster(data, poster): def render_poster(data, poster):
title = ox.decode_html(data.get('title', '')) title = ox.decode_html(data.get('title', ''))
director = u', '.join(data.get('director', [])) director = ox.decode_html(u', '.join(data.get('director', [])))
director = ox.decode_html(director)
year = str(data.get('year', '')) year = str(data.get('year', ''))
frame = data.get('frame') frame = data.get('frame')
timeline = data.get('timeline') timeline = data.get('timeline')

View file

@ -23,8 +23,7 @@ static_root = os.path.join(os.path.dirname(__file__), 'data')
def render_poster(data, poster): def render_poster(data, poster):
title = ox.decode_html(data.get('title', '')) title = ox.decode_html(data.get('title', ''))
director = u', '.join(data.get('director', [])) director = ox.decode_html(u', '.join(data.get('director', [])))
director = ox.decode_html(director)
year = str(data.get('year', '')) year = str(data.get('year', ''))
series = data.get('isSeries', False) series = data.get('isSeries', False)
oxdb_id = data['oxdbId'] oxdb_id = data['oxdbId']