1 # -*- coding: utf-8 -*-
2 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
5 from django.core.management.base import BaseCommand
7 from catalogue.models import Book
8 from librarian.cover import make_cover
11 class Command(BaseCommand):
12 def add_arguments(self, parser):
13 parser.add_argument('slug')
14 parser.add_argument('--width', type=int)
15 parser.add_argument('--height', type=int)
16 parser.add_argument('--bleed', action='store_true')
18 def handle(self, *args, **options):
19 slug = options['slug']
20 width = options['width']
21 height = options.get('height')
22 bleed = 20 if options['bleed'] else 0
23 wldoc = Book.objects.get(slug=slug).wldocument()
24 cover = make_cover(wldoc.book_info, width=width, height=height, bleed=bleed)
25 cover.save('%s.jpg' % slug)