X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/0cefa871f6f1253be544a39c51e1f66f536805ce..0b542d0cbe6ab3bc6df1d3f29ffecfa15c14df5b:/librarian/cover.py?ds=inline diff --git a/librarian/cover.py b/librarian/cover.py index a37b911..efb2974 100644 --- a/librarian/cover.py +++ b/librarian/cover.py @@ -4,10 +4,10 @@ # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # import re -import Image, ImageFont, ImageDraw, ImageFilter, ImageEnhance +from PIL import Image, ImageFont, ImageDraw, ImageFilter, ImageEnhance from StringIO import StringIO from librarian import get_resource, OutputFile, URLOpener - +from os import path class Metric(object): """Gets metrics from an object, scaling it by a factor.""" @@ -258,7 +258,6 @@ class WLCover(Cover): super(WLCover, self).__init__(book_info, format=format, width=width, height=height) self.kind = book_info.kind self.epoch = book_info.epoch - self.with_logo = with_logo if book_info.cover_url: url = book_info.cover_url bg_src = None @@ -436,3 +435,27 @@ class GandalfCover(Cover): logo_bottom = 25 logo_width = 250 format = 'PNG' + +class FutureOfCopyrightCover(Cover): + width = 402 + height = 595 + background_img = 'cover.png' + format = 'PNG' + + def save(self, dest): + dest.write(open(self.background_img).read()) + + +class CoverFromFile(Cover): + def __init__(self, filename, *args, **kwargs): + super(CoverFromFile, self).__init__(*args, **kwargs) + + self.background_img = filename + + self.img = Image.open(filename) + (self.width, self.height) = self.img.size + + self.format = path.splitext(filename)[-1][1:].upper() + + def image(self): + return self.img