From e49375a84925aec73ac257c9fb4d537c5e7d0f27 Mon Sep 17 00:00:00 2001 From: Jan Szejko Date: Fri, 7 Apr 2017 15:42:37 +0200 Subject: [PATCH 1/1] add cover generator command --- src/catalogue/management/commands/gencover.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/catalogue/management/commands/gencover.py diff --git a/src/catalogue/management/commands/gencover.py b/src/catalogue/management/commands/gencover.py new file mode 100644 index 000000000..adb84ea00 --- /dev/null +++ b/src/catalogue/management/commands/gencover.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# +from django.core.management.base import BaseCommand + +from catalogue.models import Book +from librarian.cover import DefaultEbookCover + + +class Command(BaseCommand): + def add_arguments(self, parser): + parser.add_argument('slug') + parser.add_argument('size', type=int) + + def handle(self, *args, **options): + slug = options['slug'] + size = options['size'] + wldoc = Book.objects.get(slug=slug).wldocument() + cover = DefaultEbookCover(wldoc.book_info, width=size) + cover.save('%s.jpg' % slug) -- 2.20.1