about summary refs log tree commit diff
path: root/kcc/image.py
diff options
context:
space:
mode:
authorPaweł Jastrzębski <pawelj@iosphe.re>2015-10-25 20:04:21 +0100
committerPaweł Jastrzębski <pawelj@iosphe.re>2015-10-25 20:04:21 +0100
commita93da2136b4d109c0b13e5211fcaa0ecef2b9018 (patch)
treec6369ce47636f6ca0d597759ece29e5abe7af551 /kcc/image.py
parentEscape special characters in TOC (diff)
downloadkcc-a93da2136b4d109c0b13e5211fcaa0ecef2b9018.tar.gz
kcc-a93da2136b4d109c0b13e5211fcaa0ecef2b9018.tar.bz2
kcc-a93da2136b4d109c0b13e5211fcaa0ecef2b9018.zip
Added cover upload
Diffstat (limited to 'kcc/image.py')
-rwxr-xr-xkcc/image.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/kcc/image.py b/kcc/image.py
index dc6dbee..6dd4d98 100755
--- a/kcc/image.py
+++ b/kcc/image.py
@@ -453,3 +453,11 @@ class Cover:
             self.image.save(self.target, "JPEG", optimize=1, quality=80)
         except IOError:
             raise RuntimeError('Failed to process downloaded cover.')
+
+    def saveToKindle(self, kindle, asin):
+        self.image = self.image.resize((300, 470), Image.ANTIALIAS).convert('L')
+        try:
+            self.image.save(os.path.join(kindle.path.split('documents')[0], 'system', 'thumbnails',
+                                         'thumbnail_' + asin + '_EBOK_portrait.jpg'), 'JPEG')
+        except IOError:
+            raise RuntimeError('Failed to upload cover.')