release
[librarian.git] / scripts / book2cover
index ae11e60..3e0fd21 100755 (executable)
@@ -1,11 +1,7 @@
 #!/usr/bin/env python
-# -*- coding: utf-8 -*-
-#
 # This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
 #
-from StringIO import StringIO
-from librarian import OutputFile
 from librarian.book2anything import Book2Anything, Option
 
 
@@ -15,11 +11,16 @@ class Book2Cover(Book2Anything):
     uses_cover = True
     cover_optional = False
 
+    transform_options = [
+        Option('-W', '--width', action='store', type='int', dest='width', default=None,
+                help='Set width.'),
+        Option('-H', '--height', action='store', type='int', dest='height', default=None,
+                help='Set height.'),
+    ]
+
     @staticmethod
-    def transform(wldoc, cover):
-        output = StringIO()
-        cover(wldoc.book_info).save(output)
-        return OutputFile.from_string(output.getvalue())
+    def transform(wldoc, cover, *args, **kwargs):
+        return wldoc.as_cover(cover_class=cover, *args, **kwargs)
 
 
 if __name__ == '__main__':