2 # -*- coding: utf-8 -*-
4 # This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
5 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
10 from librarian import ParseError
11 from librarian.parser import WLDocument
12 from librarian.cover import WLCover
15 if __name__ == '__main__':
16 # Parse commandline arguments
17 usage = """Usage: %prog [options] SOURCE [SOURCE...]
18 Create cover images for SOURCE files."""
20 parser = optparse.OptionParser(usage=usage)
22 parser.add_option('-v', '--verbose', action='store_true', dest='verbose', default=False,
23 help='print status messages to stdout')
25 options, input_filenames = parser.parse_args()
27 if len(input_filenames) < 1:
32 for input_filename in input_filenames:
36 output_filename = os.path.splitext(input_filename)[0] + '.jpg'
38 doc = WLDocument.from_file(input_filename)
39 WLCover(doc.book_info).save(output_filename)