X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/ea995d6aea1cc1b19502825fec5f5d0445d632c4..6a2a1ba8ab5cad50af8dc0b1ec0387e4e4f41f4b:/librarian/cover.py diff --git a/librarian/cover.py b/librarian/cover.py index 1db96cb..2320f19 100644 --- a/librarian/cover.py +++ b/librarian/cover.py @@ -4,7 +4,7 @@ # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # import re -import Image, ImageFont, ImageDraw, ImageFilter +from PIL import Image, ImageFont, ImageDraw, ImageFilter from StringIO import StringIO from librarian import get_resource, IOFile @@ -113,12 +113,12 @@ class Cover(object): exts = { 'JPEG': 'jpg', 'PNG': 'png', - } + } mime_types = { 'JPEG': 'image/jpeg', 'PNG': 'image/png', - } + } def __init__(self, book_info, format=None): try: @@ -154,24 +154,22 @@ class Cover(object): top = self.author_top tbox = TextBox( self.width - self.author_margin_left - self.author_margin_right, - self.height - top, - ) + self.height - top) author_font = self.author_font or ImageFont.truetype( get_resource('fonts/DejaVuSerif.ttf'), 30) tbox.text(self.pretty_author(), self.author_color, author_font, - self.author_lineskip, self.author_shadow) + self.author_lineskip, self.author_shadow) text_img = tbox.image() img.paste(text_img, (self.author_margin_left, top), text_img) top += text_img.size[1] + self.title_top tbox = TextBox( self.width - self.title_margin_left - self.title_margin_right, - self.height - top, - ) + self.height - top) title_font = self.author_font or ImageFont.truetype( get_resource('fonts/DejaVuSerif.ttf'), 40) tbox.text(self.pretty_title(), self.title_color, title_font, - self.title_lineskip, self.title_shadow) + self.title_lineskip, self.title_shadow) text_img = tbox.image() img.paste(text_img, (self.title_margin_left, top), text_img)