ae11e60437df25f7750098b2dde103a72041fc5b
[librarian.git] / scripts / book2cover
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 #
4 # This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
5 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
6 #
7 from StringIO import StringIO
8 from librarian import OutputFile
9 from librarian.book2anything import Book2Anything, Option
10
11
12 class Book2Cover(Book2Anything):
13     format_name = "JPEG"
14     ext = "jpg"
15     uses_cover = True
16     cover_optional = False
17
18     @staticmethod
19     def transform(wldoc, cover):
20         output = StringIO()
21         cover(wldoc.book_info).save(output)
22         return OutputFile.from_string(output.getvalue())
23
24
25 if __name__ == '__main__':
26     Book2Cover.run()