From: Jan Szejko Date: Fri, 7 Apr 2017 13:42:37 +0000 (+0200) Subject: add cover generator command X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/e49375a84925aec73ac257c9fb4d537c5e7d0f27?ds=inline add cover generator command --- 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)