from librarian import DirDocProvider, ParseError
from librarian.parser import WLDocument
-from librarian.cover import WLCover
+from librarian.cover import DefaultEbookCover
class Option(object):
if cls.uses_cover:
if options.image_cache:
def cover_class(*args, **kwargs):
- return WLCover(image_cache=options.image_cache, *args, **kwargs)
+ return DefaultEbookCover(image_cache=options.image_cache, *args, **kwargs)
transform_args['cover'] = cover_class
elif not cls.cover_optional or options.with_cover:
- transform_args['cover'] = WLCover
+ transform_args['cover'] = DefaultEbookCover
# Do some real work
format = 'JPEG'
scale = 1
+ scale_after = 1
exts = {
'JPEG': 'jpg',
if format is not None:
self.format = format
scale = max(float(width or 0) / self.width, float(height or 0) / self.height)
- if scale:
+ if scale >= 1:
self.scale = scale
+ elif scale:
+ self.scale_after = scale
def pretty_author(self):
"""Allows for decorating author's name."""
return img
+ def final_image(self):
+ img = self.image()
+ if self.scale_after != 1:
+ img = img.resize((
+ int(round(img.size[0] * self.scale_after)),
+ int(round(img.size[1] * self.scale_after))),
+ Image.ANTIALIAS)
+ return img
+
def mime_type(self):
return self.mime_types[self.format]
return self.exts[self.format]
def save(self, *args, **kwargs):
- return self.image().save(format=self.format, quality=95, *args, **kwargs)
+ return self.final_image().save(format=self.format, quality=95, *args, **kwargs)
def output_file(self, *args, **kwargs):
imgstr = StringIO()
class WLCover(Cover):
- """Default Wolne Lektury cover generator."""
+ """Wolne Lektury cover without logos."""
width = 600
height = 833
uses_dc_cover = True
logo_bottom = 25
logo_width = 250
format = 'PNG'
+
+
+DefaultEbookCover = LogoWLCover
+
from shutil import rmtree
from librarian import RDFNS, WLNS, NCXNS, OPFNS, XHTMLNS, OutputFile
-from librarian.cover import WLCover
+from librarian.cover import DefaultEbookCover
from librarian import functions, get_resource
if cover:
if cover is True:
- cover = WLCover
+ cover = DefaultEbookCover
cover_file = StringIO()
bound_cover = cover(document.book_info)
from tempfile import NamedTemporaryFile
from librarian import OutputFile
-from librarian.cover import WLCover
+from librarian.cover import DefaultEbookCover
from librarian import get_resource
# provide a cover by default
if not cover:
- cover = WLCover
+ cover = DefaultEbookCover
cover_file = NamedTemporaryFile(suffix='.png', delete=False)
bound_cover = cover(book_info)
bound_cover.save(cover_file)
subprocess.check_call(['ebook-convert', epub.get_filename(), output_file.name,
'--no-inline-toc', '--cover=%s' % cover_file.name], **kwargs)
os.unlink(cover_file.name)
- return OutputFile.from_filename(output_file.name)
\ No newline at end of file
+ return OutputFile.from_filename(output_file.name)
#
from librarian import ValidationError, NoDublinCore, ParseError, NoProvider
from librarian import RDFNS
-from librarian.cover import WLCover
+from librarian.cover import DefaultEbookCover
from librarian import dcparser
from xml.parsers.expat import ExpatError
def as_cover(self, cover_class=None, *args, **kwargs):
if cover_class is None:
- cover_class = WLCover
+ cover_class = DefaultEbookCover
return cover_class(self.book_info, *args, **kwargs).output_file()
def save_output_file(self, output_file, output_path=None,
from librarian.parser import WLDocument
from librarian import ParseError, DCNS, get_resource, OutputFile
from librarian import functions
-from librarian.cover import WLCover
+from librarian.cover import DefaultEbookCover
functions.reg_substitute_entities()
if cover:
if cover is True:
- cover = WLCover
+ cover = DefaultEbookCover
bound_cover = cover(book_info)
root.set('data-cover-width', str(bound_cover.width))
root.set('data-cover-height', str(bound_cover.height))